cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnthonyJrJr
Frequent Visitor

Filter List using Gallery Selection (Gallery.Selected.Value)

Hi there,

 

I know this question has been posted multiple times, but I just cannot understand how to "ignore" label.value and show all data when button is pressed in order to filter a SP list.

 

SP list name = [@'Employee Tasks']

 

Current filter which is working:

 

SortByColumns((Filter([@'Employee Tasks'], (Manager.Email = varUserEmail && Active.Value = "Active" && Status.Value = cpManagerTaskStatusFilter1.Selected.Value))
), "TaskCategory", If(SortDescending1, Descending, Ascending), "SortByPriority", If(SortDescending1, Descending, Ascending))

 

And what I'm trying to do is - add Gallery with 4 buttons to add an extra layer of filtering to this

 

Gallery1.Items = ["All","Cat 1","Cat 2","Cat 3"]

 

My goal is to filter based on task category which are stored in the SP list, and I have 3 categories ("Cat 1", "Cat 2" and "Cat 3"), but what I don't have is category called = "All", so when I pass the value of "All" to the filter, of course it is not working.

 

What I want to do is to get something like this, but with the condition if Gallery1.Selected.Value = "All" to get back all data for all 3 categories

 

SortByColumns((Filter([@'Employee Tasks'], (Manager.Email = varUserEmail && Active.Value = "Active" && Status.Value = cpManagerTaskStatusFilter1.Selected.Value)
&& 'Task Category' = Gallery1.Selected.Value)), "TaskCategory", If(SortDescending1, Descending, Ascending), "SortByPriority", If(SortDescending1, Descending, Ascending))

 

 

The syntax should be something like this

 

If(Gallery1.Selected.Value = "All" ---- return ALL values from sharepoint list "New Employee" // IGNORE Category value)
If(Gallery1.Selected.Value = "Cat 1" -- return values from sharepoint list where 'Task Category' = "Cat 1")

And so on for "Cat 2" and "Cat 3"

 

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @AnthonyJrJr ,

Try this format

SortByColumns(
   Filter(
      [@'Employee Tasks'], 
      Manager.Email = varUserEmail && 
      Active.Value = "Active" && 
      Status.Value = cpManagerTaskStatusFilter1.Selected.Value &&
      (
         Gallery1.Selected.Value = "All" ||
         'Task Category' = Gallery1.Selected.Value
      )
   ),
   "TaskCategory", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   ), 
   "SortByPriority", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

2 REPLIES 2
WarrenBelz
Super User
Super User

Hi @AnthonyJrJr ,

Try this format

SortByColumns(
   Filter(
      [@'Employee Tasks'], 
      Manager.Email = varUserEmail && 
      Active.Value = "Active" && 
      Status.Value = cpManagerTaskStatusFilter1.Selected.Value &&
      (
         Gallery1.Selected.Value = "All" ||
         'Task Category' = Gallery1.Selected.Value
      )
   ),
   "TaskCategory", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   ), 
   "SortByPriority", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz Thank you!!!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,228)