How to filter a gallery by using buttons

Iron Contributor

Hi there,
I have 2 buttons

In Progress and Complete

I have set 2 variables

- varbtnCompleteTab and  
 -varbtnInProgressTab

 

I have set the variables like so on the button OnSelect
Set(varbtnInProgressTab,"New")

and Set(varbtnCompleteTab,"Complete")

 

On the items Gallery I have 

If(varbtnCompleteTab = "Complete",
Filter('DataSource','Event Status'= varbtnCompleteTab),If(varbtnInProgressTab ="New",Filter('ESC-Request','Event Status'= varbtnInProgressTab)))

 

When i load the app and select the first button In Progress it filters and also the second one (Complete button).

 

My Problem :
But when i click it again it does nothing and also when i load the app the first time there is no data until i press the button?

 

What am i doing wrong?

Thanks

 

 

 

 

8 Replies

Hi @Patrick Rote, your IF-Logic maybe causing the unexpected, but logically the App is alright. At the first Runtime your logic can select from the filter criteria, but only from the first IF. The next, nested IF Funktion does not find any Data left then...

I would like to suggest, that your IF Logic can be simplified with the SWITCH (this OR This OR This OR That :)) Function,

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-if

only an idea... With that function two filters can be reviewed at the same (run)time.

Another idea: you can nest your 2 variables in items of a criteria "collection" to choose from.

 

To get a very good introduction for free: Laura Rogers published to today an invitation to register for a powerapps free training day! I highly recommend her brilliant learning content to you, she explains it in an understanding manner: https://www.iwmentor.com/courses/powerapps-introduction

 

Hope that helps, Greets from Eva.

 

 

Thanks Eva. The link you sent is in german. I wished i understood.
Can please give me of an example using the switch. I'm a bit novice to powerapps

Hi @Patrick Rote, I am sorry for this :facepalm:.

In fact translating is easy, when you look at microsofts hyperlinks: In the position of "de-de" of the URL you only have to replace it with "en-us", I adjusted this URL and you can now read in english. Never mind. I added you a useful link to learn more about PowerApps: The best content I fould so far is in Laura Rogers' Site, called iwmentor.com. You can follow her tons of videos from 2017 concerning Power Automate and PowerApps as well. She's the best. Enjoy learning, as i still do :cool:

 

Eva

Hi @Eva Vogel 

I tried the below using switch

Switch(varbtnInProgressTab, "New", Filter('ESC-Request','Event Status'= varbtnInProgressTab), "Complete", Filter('ESC-Request','Event Status'= varbtnCompleteTab))

 But i had no luck.
It doesn't load anything by default(When i load the gallery initially)
When i click the In Progress button it works the first time and letter it doesn't work or refresh.

 

What am i missing

Hi @Patrick Rote, sorry for late answer, am very busy... Theres a good video for you from April Dunham about Filtering a List in PowerApps with a Filter Button.

https://youtu.be/8bNCBe2wzYI?list=TLPQMTAxMTIwMjBDVerNQxedog&t=563

There are so many ways to filter, she knows them all 🙂

 

Have a good day,

Eva

PowerApps #Sorting This Beginner Fundamentals Quick Tip is all about Power Apps Sorting. You'll learn the basics of sorting including how to plan for sorting with delegation in mind, how to sort by multiple columns, how to add sorting in combination with filtering and more! Table of Contents: ...

Thanks @Eva Vogel for the videos

But there wasn't any example filtering gallery by using multiple buttons..

I think i'm close looking at my OP but just having issue combining multiple filters

 

Thanks @Eva Vogel  I ended up using dropdown list instead of buttons.
It was clearer to me that using different buttons to filter...
Hope i get to see how its is being used soon

@Patrick Rote If you still require this you can try the following

 

you can set the Filter(Datasorcename, Progress = VarbtnInProgressTab, Complete = varbtnCompleteTab)