cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Responsive Resident
Responsive Resident

Gallery Filtering

Hello everyone,

 

What i am trying to do is the following. i have a start screen with many buttons that lead to another screen which has a gallery that holds my data items. But based on the buttons on the start screen, each one should filter out my gallery accordingly, how can i do this.

 

thank you

1 ACCEPTED SOLUTION

Accepted Solutions

It can, yes.

If you're just substituting different values into the "StartsWith" construction, you just have to pass different variables.

On the other hand, if your actual filter criteria changes, you will need:

...1) different Filter() statements referencing

...2) different Context Variables, and...

...3) another Context Variable that tells the Gallery which Filter statement to apply (let's call it: whichFilter)

 

Then, each button will have to pass the right variables in their Navigate() statement, AND they will have to pass the whichFilter variable.

 

Your Items property would then include an If() statement:

If (
    whichFilter = "Button1",       // Button1 sent us to this form and filled the variables
    Filter(...),                   // filter using Button1's variables
    whichFilter = "Button2",       // Button2 sent us to this form and filled the variables
        Filter(...),               // filter using Button2's variables
        Filter(...)                // default case, Button3 sent us and we'll use those variables
)

Depending on how many cases you had to test for, a Switch() statement might simplify that.

View solution in original post

6 REPLIES 6
Highlighted
Microsoft
Microsoft

Hello @mmattar,

The following should work:

1. Use the following formula for your Gallery (paste it into gallerie's Items property): Filter(CustomGallerySample, SampleHeading=filterCriteria)

2. Use the following parameter with your Navigate command (paste the formula into button's OnSelect property): 

Navigate(Screen1, ScreenTransition.Cover, {filterCriteria:"Lorem ipsum 1"})

Highlighted
Responsive Resident
Responsive Resident

just so im understanding correctly, here is my formula that i put into my galleries items.

SortByColumns(Filter(TRACAgenda,StartsWith(mlpo.DisplayName,TextInput1.Text)||StartsWith(o0fc,TextInput1.Text)),"TRACMeetingDate",If(sortDescending1,Descending,Ascending))

 

Now on my start screen where i have my button, i have: (i left out the sorting in the filter because it is giving me error, i believe because i am decalring a variable on the gallery screen and not the start screen.

 

Navigate(TracInitiative,ScreenTransition.Cover,{filtercriteria: Filter(TRACAgenda,StartsWith(mlpo.DisplayName,TextInput1.Text)||StartsWith(o0fc,TextInput1.Text))})

Highlighted

Your Items property on the Gallery would be:

Filter(TRACAgenda,StartsWith(mlpo.DisplayName,filterCriteria)||StartsWith(o0fc,filterCriteria))

And your Navigate statement would only pass the TextInput1.Text as the variable:

Navigate(TracInitiative,ScreenTransition.Cover,{filterCriteria: TextInput1.Text})

 

If, for whatever reason, you wanted a different variable in your second filter criteria, just have 2 variables, and then pass those 2. Let's say the second "StartsWith" parameter came from another TextInput, this one named "TextInput2". Your Items would read:

Filter(TRACAgenda,StartsWith(mlpo.DisplayName,filterCriteria1)||StartsWith(o0fc,filterCriteria2))

 And your Navigate statement would pass both variables: 

Navigate(TracInitiative,ScreenTransition.Cover,{filterCriteria1: TextInput1.Text, filterCriteria2: TextInput2.Text})

 

Highlighted
Responsive Resident
Responsive Resident

ok thanks! but what if i have another button that does a different filter, i want to use the same gallery. does the items property in the gallery change ? 

It can, yes.

If you're just substituting different values into the "StartsWith" construction, you just have to pass different variables.

On the other hand, if your actual filter criteria changes, you will need:

...1) different Filter() statements referencing

...2) different Context Variables, and...

...3) another Context Variable that tells the Gallery which Filter statement to apply (let's call it: whichFilter)

 

Then, each button will have to pass the right variables in their Navigate() statement, AND they will have to pass the whichFilter variable.

 

Your Items property would then include an If() statement:

If (
    whichFilter = "Button1",       // Button1 sent us to this form and filled the variables
    Filter(...),                   // filter using Button1's variables
    whichFilter = "Button2",       // Button2 sent us to this form and filled the variables
        Filter(...),               // filter using Button2's variables
        Filter(...)                // default case, Button3 sent us and we'll use those variables
)

Depending on how many cases you had to test for, a Switch() statement might simplify that.

View solution in original post

Highlighted
Responsive Resident
Responsive Resident

Bam! thats what i needed, thanks !

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (4,332)