cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ahhollan
Helper V
Helper V

Use button to filter by a value range

I have built an app with records that have a data field of Days Old.  I'd like to filter the main gallery using buttons. For example, when I press a button, it should only return records with values of 0 to 5 in the Days Old field.  How do I accomplish this? I'm going to have one button for all fields, one for <5 days, one for 6-10 days, and one for >10 days.

1 ACCEPTED SOLUTION

Accepted Solutions

You had one extra parenthesis:

Filter(
'Alarm Tracking',
(variable1 && Value('Days Old')<5 && Value('Days Old')>0)
||
(variable2 && Value('Days Old')>6 && Value('Days Old')<10)
||
(variable3 && Value('Days Old')>10)
||
(!variable1 && !variable2 && !variable3)
)

Let me know if this works.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com

View solution in original post

7 REPLIES 7
PowerAddict
Super User
Super User

For each button's OnSelect, set a variable to true. Then set the Items property of your gallery to:

Filter(Entity, If(variable1, 'Days Old' < 5 && 'Days Old' > 0, true), If(variable2, 'Days Old' > 6 && 'Days Old' < 10, true), If(variable3, 'Days Old' > 10, true)

Button1 Onselect = Set(variable1, true)
Button2 Onselect = Set(variable2, true)
Button3 Onselect = Set(variable3, true)

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com

The buttons aren't working. The gallery doesn't return records for any of the buttons.  My formula (i had to alter a little) is Filter('Alarm Tracking',If(variable1,Value('Days Old')<5 && Value('Days Old')>0, true),If(variable2,Value('Days Old')>6 && Value('Days Old')<10, true),If(variable3,Value('Days Old')>10, true)).

 

Also, what do I add so that the All Tickets button returns all records?

The All Tickets should simply do the following OnSelect

Set(variable1, false);
Set(variable2, false);
Set(variable3, false)

Let me do a quick check to see why it isn't working for you.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com

I have attached a GIF that shows a simple test I did using a scenario similar to yours. Here are the important values from the test:

 

OnSelect of Variable1 Button: 

Set(variable1, true); Set(variable2, false); Set(variable3, false)

OnSelect of Variable2 Button:

Set(variable2, true); Set(variable1, false); Set(variable3, false)

OnSelect of Variable3 Button:

Set(variable3, true); Set(variable1, false); Set(variable2, false)

OnSelect of All Accounts Button:

Set(variable1, false); Set(variable2, false); Set(variable3, false)

Items property of the Gallery:

Filter(Accounts, (variable1 && 'Account Name'= "Account One") || (variable2 && 'Account Name' = "Fourth Coffee (sample)") || (variable3 && 'Account Name' = "Adventure Works (sample)") || (!variable1 && !variable2 && !variable3))

 

Based on this example, your formulas should be something like the following: 

Items property of the Gallery:

Filter('Alarm Tracking', (variable1 && Value('Days Old')<5) && Value('Days Old')>0, true) || (variable2 && Value('Days Old')>6 && Value('Days Old')<10) || (variable3 && Value('Days Old')>10) || (!variable1 && !variable2 && !variable3))

OnSelect of Variable1 Button: 

 

Set(variable1, true); Set(variable2, false); Set(variable3, false)

 

OnSelect of Variable2 Button:

 

Set(variable2, true); Set(variable1, false); Set(variable3, false)

 

OnSelect of Variable3 Button:

 

Set(variable3, true); Set(variable1, false); Set(variable2, false)

 

OnSelect of All Tickets Button:

 

Set(variable1, false); Set(variable2, false); Set(variable3, false)

 

Let me know if this helps. 

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://thepoweraddict.com

 

 

 

 

I'm having trouble with the Items formula. When I get to the 2nd variable and input Value, 'Days Old' is not a choice for the field but 'Days Old Datacard' is. 

 

Filter('Alarm Tracking', (variable1 && Value('Days Old')<5) && Value('Days Old')>0, true) || (variable2 && Value('Days Old')>6 && Value('Days Old')<10) || (variable3 && Value('Days Old')>10) || (!variable1 && !variable2 && !variable3))

You had one extra parenthesis:

Filter(
'Alarm Tracking',
(variable1 && Value('Days Old')<5 && Value('Days Old')>0)
||
(variable2 && Value('Days Old')>6 && Value('Days Old')<10)
||
(variable3 && Value('Days Old')>10)
||
(!variable1 && !variable2 && !variable3)
)

Let me know if this works.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com

View solution in original post

What if i also wanted to exclude rows where the field Condition had a status of 'Resolved'? Would that just be adding the following to the items formula for the gallery?  &&Condition<>"Resolved"

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,759)