cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UserInterface7
Level: Powered On

Help with filter on Gallery

Hi, I am trying to build a little storefront but I am still having trouble with filtering.

 

I have a List called, 'Store Data - Categories' with the Title field renamed to 'CategoryName' and another list called 'Store' also with a filed called 'CategoryName'

In my app, I have two galleries 'Options' (which is the 'Store' List in SP) and 'Categories' (which is 'Store Data - Categories' in SP)

 

I am trying to only show the items (from 'Options') that match the selected category, I tried this but it doesn't work.

SortByColumns(Filter('Store Data - Categories', And(Title = Categories.Selected)))

 

Can anyone help? Think I might just be confused because I named my Galleries differently to the SP List and I'm not sure what the filter is requiring, but I have tried different combos and they didn't work.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Help with filter on Gallery

Changing the control name to GroupLabel doesn't impact the how we are trying to use Group which is actual field name.

 

If you haven't a variable called SortDescending1 that explains why it said the if statement was invalid.

 

You can still sort by doing this:

 

SortByColumns(
Filter(
'XXXXX Store',
Group = Category.Selected.Title
),
"Group",
Ascending
)

 

 

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

14 REPLIES 14
UserInterface7
Level: Powered On

Re: Help with filter on Gallery

OK. Based on another post I think this might be closer but it still fails.

 

SortByColumns(Filter(Categories, ("CatagoryName" = Categories.Selected.CatagoryName in CatagoryName)), "CatagoryName", If(SortDescending1, Descending, Ascending)) 

Highlighted
Super User
Super User

Re: Help with filter on Gallery

Try this in the Item properties of the second gallery ('Categories').

 

SortByColumns(
  Filter(
    'Store Data - Categories', 
    Title = Options.Selected.CatagoryName
  ), 
  "Title", If(SortDescending1, Descending, Ascending)
) 

This assumes the first gallery is named Options ('Store' List in SP) and the Title column that was renamed is in the Categories gallery ('Store Data' list in SP).



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
UserInterface7
Level: Powered On

Re: Help with filter on Gallery

The assumptions are correct but I get an error 'This rule creates a circular reference between properties, which is not allowed. A property cannot reference itself or other properties affected by its value.' Is that because I gave the field the same name in both tables?

 

 

UserInterface7
Level: Powered On

Re: Help with filter on Gallery

OK. I have recreated and named everything a bit better so that I would be less confused. I feel like what I now have should work, but I must still be missing something.

 

SortByColumns(Filter('XXXXXX Store',GroupLabel=Category.Selected.CategoryName),Group,If(SortDescending1, Descending, Ascending))

 

'XXXXXX Store' is the name of the SP list that contains all the asset information. It seems to only work when I give this name, not the 'Store' name that is in my app.

 

All the highlighting seems correct, but it is failing on the sort for some reason.

 

I also recreated the column one the SP list as I think it was getting confused with them having the same name.

Super User
Super User

Re: Help with filter on Gallery

I am not sure if I understand what is in each gallery but lets give it another try. Add this to the Items property of the Options gallery. 'Something Store' should be the name of the list that populates the options gallery (the gallery with all the laptop pics).

 

SortByColumns(
  Filter(
    'Somthing Store', 
	CategoryName = Categories.Selected.Title
  ),
  "CategoryName", If(SortDescending1, Descending, Ascending)
)


--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
UserInterface7
Level: Powered On

Re: Help with filter on Gallery

Hey Jeff, I have just edited my last post as even I was getting confused. 

I have a gallery called Category which uses a data source SP list of 'XXXXX - Store Data Categories', The Title field on the SP List holds the info (Desktops/Laptops etc)

I have a second gallery called Store, which uses a data source SP list called 'XXXXX Store', on this one I now have a field called 'Group' that holds a matching group name (Desktops/Laptops etc).

 

Hopefully, that is less confusing.. 

 screen4.png

 

Super User
Super User

Re: Help with filter on Gallery

Is the new field "Group" or "GroupLabel"? The screenshot shows "GroupLabel". The new field is a Text field and not a choice or lookkup field?

 

Based on what I understand the Items Property should look something like this:

SortByColumns(
  Filter(
    'XXXXX Store', 
	Group = Category.Selected.Title
  ),
  "Group", If(SortDescending1, Descending, Ascending)
)

The first gallery (Category) just has 'XXXXX - Store Data Categories' in the Items properties?



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
UserInterface7
Level: Powered On

Re: Help with filter on Gallery

New filed is called 'Group' in the SP List (Sharepoint Online), and 'GroupLabel' in the Gallery. When I tried to use the same name in the gallery it was giving an error and making the field black, so I added label to the end of the name to get around that problem.

 

It is now just a plain text field as before it was a Choice and I couldn't see it to add it to the gallery.

 

When I try your code I get the same issue as before "The function 'If' has some invalid arguments"

 

And yes, the first gallery (that has the category images) just has 'XXXXX - Store Data Categories' in the Items properties

UserInterface7
Level: Powered On

Re: Help with filter on Gallery

I thought this was correct. 

SortByColumns(Filter('XXXXX Store',GroupLabel=Category.Selected.CategoryName),Group,If(SortDescending1, Descending, Ascending))

When i look at the highlighting in the image, it looks like it is doing the right thing..

Just when i click it doesn't do anything, although, it also gets same error "The function 'If' has some invalid arguments"

 

Just adding in my SP list names and Columns 

screen6.PNGscreen5.png

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,713)