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

Using a button to filter a gallery

Hello,

 

Is there a way I can use a button to filter some results in my gallery based on an output of a label.  There is a label in my gallery which holds a text output if another argument is true.  The text output held by the label is "CAB".  I need to be able to press a button and for all of the labels with the "CAB" value to be displayed.  Is there a way of doing this? (Sorry I'm new to Powerapp design)

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @Station1901,

Do you want to filter your Gallery items based on an output of a label when you click a button?

I have made a test on my side, please take a try with the following workaround:

Set the OnVisible property of the first screen of your app to following:

ClearCollect(RecordsCollection, 'YourDataSource')

or

ClearCollect(RecordsCollection, 'The formula you typed within the Items property of your Gallery control')    /* <-- Save your Original Gallery items into a Collection */

Set the Items property of your Gallery control to following:

RecordsCollection

Set the OnSelect property of the Button control (that you clicked) to following formula:

ClearCollect(
  RecordsCollection,
  Filter(RecordsCollection,FilteredColumn=Label1.Text)
)

Note: The FilteredColumn represents the column in your data source, which you want to filter your Gallery items based on. The Label1 represents the Label control that you mentioned.

 

More details about the Filter function in PowerApps, please check the following article:

Filter function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Super User II
Super User II

Hi @Station1901,

There is certainly a way to do what you are trying to do.  It could be done using the UpdateContext() function and would be based on the formula that you use to derive the Text property of your label. Please let me know this formula and I can proceed. 

Community Support
Community Support

Hi @Station1901,

Do you want to filter your Gallery items based on an output of a label when you click a button?

I have made a test on my side, please take a try with the following workaround:

Set the OnVisible property of the first screen of your app to following:

ClearCollect(RecordsCollection, 'YourDataSource')

or

ClearCollect(RecordsCollection, 'The formula you typed within the Items property of your Gallery control')    /* <-- Save your Original Gallery items into a Collection */

Set the Items property of your Gallery control to following:

RecordsCollection

Set the OnSelect property of the Button control (that you clicked) to following formula:

ClearCollect(
  RecordsCollection,
  Filter(RecordsCollection,FilteredColumn=Label1.Text)
)

Note: The FilteredColumn represents the column in your data source, which you want to filter your Gallery items based on. The Label1 represents the Label control that you mentioned.

 

More details about the Filter function in PowerApps, please check the following article:

Filter function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

hey @v-xida-msft,

 

Is it still possible to use this if the column in sharepoint I am filtering on is a choice column?

 

Thanks,

Aimee

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (63,217)