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
Solved! Go to Solution.
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"))
)
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.
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,
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