cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Gallery with 6 filter button updatecontext

Hi Guys,

 

I am new to Powerapps and wanted to create a tool where I have 6 different buttons for each team based on the selection it will filter my gallery.

 

I have created for each button onselect:

UpdateContext({FilterATeam:!FilterATeam})

UpdateContext({FilterBTeam:!FilterBTeam})

UpdateContext({FilterCTeam:!FilterCTeam})

UpdateContext({FilterDTeam:!FilterDTeam})

etc

 

When It comes to write the formula in the gallery I tried something like Filter(MySP,If(FilterAteam=true,Title="Ateam",false)) but I don't know how could I add the rest of the updatecontext formulas in the gallery together.

 

Thank you for the help

 

2 REPLIES 2
Regular Visitor

You can do a crazy nested If Function, but I think this is easier an cleaner. If you don't like it, I can help you write the nested If Funtion. I'm new at this too, so check my syntax! 

 

Use ONE Context Variable - so for each button's onselect:

Button for Team A: UpdateContext({cvarteamtofilter:TeamA})

Button for Team B: UpdateContext({cvarteamtofilter:TeamB})

Button for Team C: UpdateContext({cvarteamtofilter:TeamC})

Button for Team 😧 UpdateContext({cvarteamtofilter:TeamD})

 

Then on your Gallery Items

Filter(Sparepointlistname,Spharepointlistcolumn,

Switch(cvarteamtofilter

TeamA, "Team A",

TeamB, "Team B",

TeamC, "Team C",

TeamD, "Team D"

))

 

This is saying filter this sharepoint list's column based on the value of the context variable. 

Switch(contextvariablename,

"variablevalue=this", "return this value into he Filter function",

"variablevalue=that", "return this value into he Filter function",)

 

You can add as many things to switch the output value as you have option 

Again, I am new - so my question, or where I will have to play with it - I'm not sure if the context variable values have to be in quotes. 

 

 

Regular Visitor

Seriously, I am working through a similar scenario, so I as I do, I'm seeing other things that need to be set. 

On the form's onvisable property, set the context variable to something else, maybe "AllTeams". and add this to your switch funtion inputs/outputs to filter by all too.  

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.

Top Solution Authors
Top Kudoed Authors
Users online (83,980)