cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Station1901
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
v-xida-msft
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
Drrickryp
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. 

v-xida-msft
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (52,739)