web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Use button to filter b...
Power Apps
Answered

Use button to filter by a value range

(0) ShareShare
ReportReport
Posted on by 576

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.

Categories:
I have the same question (0)
  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    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
  • ahhollan Profile Picture
    576 on at

    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?

  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    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
  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at

    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

     

     

     

     

    FilteringUsingButton.gif
  • ahhollan Profile Picture
    576 on at

    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))

  • Verified answer
    PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    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
  • ahhollan Profile Picture
    576 on at

    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"

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard