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

Filter gallery items further filtered by button

I have a gallery that item is set to:

 

Filter(SRTask,AssignedTo.Email=User().Email)

 

I then want to create 2 buttons to futher filter the data. 

I have a yes/no field (ech_x0020_Completed_x003f_)on if item is complete. 

 

Button1 (Active): Filter gallery to only show that users active items

Filter(SRTask,Tech_x0020_Completed_x003f_=true,true,false) Getting error message: Warning: This predicate is a literal value and does not reference the input table.

 

Button2(Complete): Filter gallery to only show that users completed items

 

 

Any ideas for these buttons?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DileepGolla
Level 8

Re: Filter gallery items further filtered by button

I have tested the following approach and it is working fine. Please try this hopefully this approach should work fine for you.

 

Screen.Visible -> ClearCollect(SRTask_col,Filter(SRTask,AssignedTo.Email=User().Email)); ClearCollect(SRTask_Backup_col,SRTask_col) 

Button1, OnSelect-> ClearCollect(SRTask_col,Filter(SRTask_Backup_col,Tech_x0020_Completed_x003f_=true))

Button2, OnSelect-> ClearCollect(SRTask_col,Filter(SRTask_Backup_col,Status="Completed"))

Button3,OnSelect-> ClearCollect(SRTask_col,SRTask_Backup_col)

Gallery.Items-> SRTask_col

 

View solution in original post

9 REPLIES 9
DileepGolla
Level 8

Re: Filter gallery items further filtered by button

Hi,

 

There is one work around to achive this. You can multiple collections and filter function for this.

 

Here, I am assuming SRTask is data from a SPList. Create a collection using filter on Screen Visible. ClearCollect(SRTask_col,Filter(SRTask,AssignedTo.Email=User().Email)).

 

Button1, OnSelect-> ClearCollect(SRTask_Active_col,Filter(SRTask_col,Tech_x0020_Completed_x003f_=true))

 

Button2,OnSelect-> ClearCollect(SRTask_Completed_col,Filter(SRTask_Active_col,Status="Completed"))

 

The reason I am using a collection on Screen Visible is to increase the form performance. You can also use a single collection to achieve this once you understad the logic behind it. Hope this helps.

 

Thanks,

Dileep

 

arichards
Level: Powered On

Re: Filter gallery items further filtered by button

So the collections are working but what do I set the gallery items equal to for it to dynamically show the collection based on button selected?

DileepGolla
Level 8

Re: Filter gallery items further filtered by button

You can mention the collection that we are creating on the Screen.visible and update the same collection everytime the button is clicked.

 

On Screen Visible-> ClearCollect(SRTask_col,Filter(SRTask,AssignedTo.Email=User().Email))

 

Button1, OnSelect-> ClearCollect(SRTask_col,Filter(SRTask,AssignedTo.Email=User().Email));ClearCollect(SRTask_Active_col,Filter(SRTask_col,Tech_x0020_Completed_x003f_=true))

 

Button2,OnSelect-> ClearCollect(SRTask_col,Filter(SRTask,AssignedTo.Email=User().Email));ClearCollect(SRTask_Completed_col,Filter(SRTask_Active_col,Status="Completed"))

 

arichards
Level: Powered On

Re: Filter gallery items further filtered by button

the collections are working but they are not showing dynamically in the gallery. What do I need to set my gallery items to to allow for these collections to show depending on which button is clicked?

DileepGolla
Level 8

Re: Filter gallery items further filtered by button

You can use the IsEmpty() function to achieve this.

 

On the Items porperty of the Gallery, If(!IsEmpty(SRTask_Completed_col),SRTask_Completed_col,If(!IsEmpty(SRTask_Active_col),SRTask_Active_col,SRTask_col)).

 

This formula first checks if the SRTask_Completed_col is empty, and if it is not emtly this collection will be displayed in the gallery. Else, it will check if  SRTask_Active_col is empty and if its not empty, it will be dispalyed. Else SRTask_col will be displayed which does not have any filters. Since we are initiating the collections on OnSelect Button property, these collections should be empty unless the buttons are clicked.

arichards
Level: Powered On

Re: Filter gallery items further filtered by button

That help with the gallery but the gallery is still not updating when I click the buttons to filter the data by active and complete.  Until a button is click I would like it to show both active and completed for signed in user, then to click the button to filter it by active or complete.

DileepGolla
Level 8

Re: Filter gallery items further filtered by button

Try implementing the following approach:

 

Screen.OnVisible -> ClearCollect(SRTask_col,Filter(SRTask,AssignedTo.Email=User().Email)),ClearCollect(SRTask_Col_ToDisplay,SRTask_col)

 

Gallery.Items-> SRTask_Col_ToDisplay

Button1.OnSelect-> ClearCollect(SRTask_Col_ToDisplay,Filter(SRTask_col,Tech_x0020_Completed_x003f_=true))

Button2.OnSelect->ClearCollect(SRTask_Col_ToDisplay,Filter(SRTask_Active_col,Status="Completed"))

Button3.OnSelect-> ClearCollect(SRTask_Col_ToDisplay,SRTask_col) //this will remove the filters and display all the items

arichards
Level: Powered On

Re: Filter gallery items further filtered by button

This is not collecting the information nor showing it in the gallery. The prior approach at least created the collection even if it did not display them in the gallery.

DileepGolla
Level 8

Re: Filter gallery items further filtered by button

I have tested the following approach and it is working fine. Please try this hopefully this approach should work fine for you.

 

Screen.Visible -> ClearCollect(SRTask_col,Filter(SRTask,AssignedTo.Email=User().Email)); ClearCollect(SRTask_Backup_col,SRTask_col) 

Button1, OnSelect-> ClearCollect(SRTask_col,Filter(SRTask_Backup_col,Tech_x0020_Completed_x003f_=true))

Button2, OnSelect-> ClearCollect(SRTask_col,Filter(SRTask_Backup_col,Status="Completed"))

Button3,OnSelect-> ClearCollect(SRTask_col,SRTask_Backup_col)

Gallery.Items-> SRTask_col

 

View solution in original post

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