cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TerrenceF
Helper I
Helper I

power apps gallery with multiple filters

Hello everyone.  I apologize if this is a rudimentary question, but I am learning power apps and I am new to the filter coding.  I have a power app that has a gallery that is linked to a SharePoint site.  I have two filters for the gallery that, separately work great (thanks @RezaDorrani).  My issue is that I need both to work together on the same gallery, but I am not sure how to combine them to do so. 

 

First code filters the gallery based on the tab selected, the signed in user and the status: 

 

If(vartabselected=1,'SP LIST NAME',vartabselected=2,Filter('SP LIST NAME',User().Email in 'Assigned To'.Email),Filter('SP LIST NAME',User().Email in 'Assigned To'.Email,Progress.Value="Pending"))

 

The second filters the gallery based on the specific selections:

 

SortByColumns(Filter('SP LIST NAME',('Due date' >= cldStart.SelectedDate && 'Due date' <= cldEnd.SelectedDate || cldStart.SelectedDate = Blank() && cldEnd.SelectedDate = Blank()) && (Progress.Value = StatusRadio.Selected.Value || StatusRadio.Selected.Value = Blank()) && (Priority.Value = PriorityRadio.Selected.Value || PriorityRadio.Selected.Value = Blank())
),"DueDate",Descending)

 

I realize the delegation issues and that is okay.  Any assistance you can provide would be greatly appreciated.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@TerrenceF 

With({_items:SortByColumns(Filter('SP LIST NAME',('Due date' >= cldStart.SelectedDate && 'Due date' <= cldEnd.SelectedDate || cldStart.SelectedDate = Blank() && cldEnd.SelectedDate = Blank()) && (Progress.Value = StatusRadio.Selected.Value || StatusRadio.Selected.Value = Blank()) && (Priority.Value = PriorityRadio.Selected.Value || PriorityRadio.Selected.Value = Blank())
),"DueDate",Descending)}, 
 If(vartabselected=1,_items,vartabselected=2,Filter('SP LIST NAME',User().Email in 'Assigned To'.Email),Filter(_items,User().Email in 'Assigned To'.Email,Progress.Value="Pending"))
)

View solution in original post

6 REPLIES 6
Drrickryp
Super User
Super User

@TerrenceF 

With({_items:SortByColumns(Filter('SP LIST NAME',('Due date' >= cldStart.SelectedDate && 'Due date' <= cldEnd.SelectedDate || cldStart.SelectedDate = Blank() && cldEnd.SelectedDate = Blank()) && (Progress.Value = StatusRadio.Selected.Value || StatusRadio.Selected.Value = Blank()) && (Priority.Value = PriorityRadio.Selected.Value || PriorityRadio.Selected.Value = Blank())
),"DueDate",Descending)}, 
 If(vartabselected=1,_items,vartabselected=2,Filter('SP LIST NAME',User().Email in 'Assigned To'.Email),Filter(_items,User().Email in 'Assigned To'.Email,Progress.Value="Pending"))
)

Thanks Drrickryp.  That worked perfectly. Never would have thought of With{_items:.  I was trying every way I thought I knew how it might go together, but it was pretty far outside my depth of knowledge. If you have a second can you give a quick explanation on how the With Items works.  The rest of the code makes sense to me, but I am not sure how that tied it together.  Thanks so much for the help.  

Drrickryp
Super User
Super User

@TerrenceF 

Sure, the way I used the With() was to create a temporary collection that is the alias for your first formula.  I then simply  inserted it into the second formula.   The beauty of the With() function is that the collection only exists while the function is running.  It is very efficient and I use it all the time, to simplify complicated formulas such as the one you created.  Shane Young has a nice video to show other uses for it.  https://www.youtube.com/watch?v=AYD2oWue7fw  

Awesome.  I appreciate the explanation

Drrickryp
Super User
Super User

Smilegif.gif

 

Drrickryp,

 

The filter noted in the top portion works great for the main vartabselected=1 which shows all of the tasks.  How can I make the filters work under the remaining gallery tabs.  This is how the gallery is filtered under the current tab structure. 

 

varTabSelected=1: all tasks 

varTabSelected=2: tasks assigned to me

varTabSelected=3: tasks pending my review

varTabSelected=4: tasks created by me

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.

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 (5,618)