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

Filter Gallery using button

I'm trying to filter a gallery via a button. I have a timesheet app with a list of working days, but I want a cover page with buttons to filter the list to reduce scrolling....

 

E.g.1 - I have a screen (which I will set to the first screen viewed when you open the app), and here I will have buttons that correspond to months of the year. In OnSelect I have added the following 'Navigate(BrowseGallery1, Fade)' which takes the user to the gallery when you click the button.

 

E.g.2 - However, I would like this command to filter the gallery to a set number of entries (days in the month)

 

E.g.3 - My gallery list is sorted by ID in Body1 which is the working day of the year. Our year starts in July, so in the example attached Friday 28th June is the 260th working day of the year. Body1 = 260

 

How do I filter my gallery so it only shows an ID range e.g. ID240 to ID260?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Filter Gallery using button

@stumac_31 

So, the gallery in the sample app I sent you before was already set to display all the months as buttons.

Also, in looking at your data - your dates are not really dates, they are broken up fields of months, days, etc.  AND, your month field is a month's full name. BUT...not to worry.

Here is the formula for the Items property of the Gallery:

Filter(Timesheet_SM, Month=Text(Date(2019,Gallery1.Selected.Value,1), "[$-en-US]mmmm"))

In this case we are converting the month seleted in the filter gallery (which is numeric) to a full name with the Text function.  We could have also changed the Items property of the Filter Gallery to have the full names of the months in them, but I'm a bit lazy when it comes to typing all the months of the year and will lean on the text function to do it for me.

 

I've attached your app with the modifications...

I added a FilterScreen with the Gallery of months.  And corrected the Formula on the BrowseGallery1 to filter.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

7 REPLIES 7
Highlighted
Community Support
Community Support

Re: Filter Gallery using button

Hi @stumac_31 ,

Do you want to filter the gallery according to month(one component of the working day field) and ID?

Would you mind showing me where the ID comes from(such as a specific column)?

As I understanding,the ID is one separate column.

Understanding from this way,I made a similar test:

Screen1:

Create two text input controls named text input1、text inout2(fill in the starting ID and ending ID),two buttons named button1、button2(Equivalent to month in your app)

Create an entity named students,two columns:student_id、infor(contain color)

Scree2:

Create a label(notify error message),a gallery

Screen1:

Set the button1’s on select: Navigate(Gallery1, Fade,{context1:"pink"})

Set the button2’s on select: Navigate(Gallery1, Fade,{context1:"red"})    test2_329.jpg

 

On your side,you may use this formula:

Navigate(Gallery1, Fade,{context1:"June"})

Navigate(Gallery1, Fade,{context1:"July"})       

     

Screen2:

Set the label’s text: If(IsEmpty(Gallery1.AllItems),"No eligible items!"," ")

Set the gallery’s items:

Filter(
             students,
                 student_id>=Value(TextInput1.Text)&&
                 student_id<=Value(TextInput2.Text)&&Text(context1) in infor
                                                                                                                           )

test3_329.jpg

 

On your side,you may use this formula:

Filter(
           datasource,
                ID>=Value(TextInput1.Text)&&
                ID<=Value(TextInput2.Text)&&Text(context1) in working day
                                                                                                                     ) 

After these practices,you can fiter the gallery’s items according to two conditions.

 

 

Best regards,

Community Support Team _ Phoebe Liu

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper III
Helper III

Re: Filter Gallery using button

Dear Phoebe

 

Thank you for your response.

 

I just need to filter the gallery by the ID field which is in Body1. You can see below that I have formatted the text as white, so it does not appear in the gallery, but the field is just a number. In the selected example the number is 260 as Friday 28th June is the 260th working day of our year (June-July).

 

I tried to follow your example but got a little lost, hopefully with just one field to filter it will be simpler….

Highlighted
Helper III
Helper III

Re: Filter Gallery using button

Dear @v-yutliu-msft 

 

Any way to filter based on text in the Title2 field? 

This field is constructed from values from 3 text columns using the following (see attached): 

ThisItem.Day & " " & ThisItem.Date & " " & ThisItem.Month

 

Could I just filter the gallery on the basis of the text found in the Title2 field?

Highlighted
Super User III
Super User III

Re: Filter Gallery using button

@stumac_31 

It seems that you want to filter your gallery on the second page by the month of your selection in the first page.

If that is the case, then I wouldn't worry about the ID's and instead focus on the dates in the data.

 

I've attached a sample app.  Download and open in PowerApps designer.  Look at the OnStart action to see the very brief sample data (note there are only entries for March and April in the sample).

Play the app.  First screen is a gallery of months of the year.  Select March or April and it will navigate to another screen with another gallery on it.  Look at the Items property of the second gallery and you will see the filter.  In there it is filtering on the Month value based on the selection in the first gallery.

 

See if that is along the lines of what you are looking for.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Helper III
Helper III

Re: Filter Gallery using button

Hi @RandyHayes 

 

Thank you very much for this, it looks exactly like what I want to do, but I'm afraid I'm struggling to follow.

I have tried to copy the same structure but not sure how to get 12 buttons in a gallery format...

I'm also not sure how to make the filter connect to the column 'month' in my source data.

 

 I have attached an export of my app and the source.

 

Highlighted
Super User III
Super User III

Re: Filter Gallery using button

@stumac_31 

So, the gallery in the sample app I sent you before was already set to display all the months as buttons.

Also, in looking at your data - your dates are not really dates, they are broken up fields of months, days, etc.  AND, your month field is a month's full name. BUT...not to worry.

Here is the formula for the Items property of the Gallery:

Filter(Timesheet_SM, Month=Text(Date(2019,Gallery1.Selected.Value,1), "[$-en-US]mmmm"))

In this case we are converting the month seleted in the filter gallery (which is numeric) to a full name with the Text function.  We could have also changed the Items property of the Filter Gallery to have the full names of the months in them, but I'm a bit lazy when it comes to typing all the months of the year and will lean on the text function to do it for me.

 

I've attached your app with the modifications...

I added a FilterScreen with the Gallery of months.  And corrected the Formula on the BrowseGallery1 to filter.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Helper III
Helper III

Re: Filter Gallery using button

Dear @RandyHayes 

 

Thank you so very much.... excellent help.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (2,081)