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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter gallery based o...
Power Apps
Unanswered

Filter gallery based on checkbox value

(0) ShareShare
ReportReport
Posted on by 531

I have a powerapp gallery where i show all my academic records as per below screenshot.

 

Iantaylor2050_0-1696766494425.png

 

There is a checkbox over the top of the gallery which states "Show Topper Only". Clicking on this should only show me first 3 topper rows from the gallery. However the code is not working properly and shows all records. May i know where i am going wrong?

 

Items property of Gallery

If(Checkbox3.Value,
 SortByColumns(
 Filter(
 Transaction,
 Email = User().Email
 ),
 "Price",
 SortOrder.Descending
 )
 ,SortByColumns(
 Filter(
 Transaction,
 Email = User().Email
 ),
 "DateTime",
 SortOrder.Descending
))

 

Topper Label visible property

If(
 First(
 SortByColumns(
 Filter(
 Transaction,
 Item_No= ThisItem.Item_No
 ),
 "Price",
 SortOrder.Descending
 )
 ).Price = Value(Label16_12.Text),
 true,
 false
)

 

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,325 Super User 2025 Season 2 on at

    @Iantaylor2050 

     

    The issue is, no matter whether you checked the box or not, you are filtering Transaction based on Email.

    My guess is on the Top, you meant to either filter by something else, or you meant to filter by Email and something else. 

     

    But both of these queries are doing the same thing. You are only Sorting by a different column, not filtering by a different column.

    If(Checkbox3.Value,
     SortByColumns(
     Filter(
     Transaction,
     Email = User().Email
     ),
     "Price",
     SortOrder.Descending
     )
     ,SortByColumns(
     Filter(
     Transaction,
     Email = User().Email
     ),
     "DateTime",
     SortOrder.Descending
    ))

     
    If you like my answer, I would really appreciate if you please Mark it as Resolved, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Iantaylor2050 Profile Picture
    531 on at

    Hi @FLMike 

     

    My intention is to show only first 3 rows when checkbox is checked, because these 3 rows have Topper label.

     

    Iantaylor2050_0-1696867978926.png

     

    Topper label is being shown based on the below check. Below is the code for visible property of Topper Label

     

    If(
     First(
     SortByColumns(
     Filter(
     Transaction,
     Item_No= ThisItem.Item_No
     ),
     "Price",
     SortOrder.Descending
     )
     ).Price = Value(Label16_12.Text),
     true,
     false
    )

     

     

  • Iantaylor2050 Profile Picture
    531 on at

    Hi @WarrenBelz 

     

    Can please help me out on the above query? 

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @Iantaylor2050 ,

    I suspect @FLMike is in a different time zone and he has also asked a pertinent question about your code. The visibility of the checkbox I do not think is relevant as you are basing the filter on whether it is checked (not whether it is visible - if it is checked by Default, it will remain so even if it is not visible). You can shorten the visibility to

    LookUp(
     Sort(
     Transaction,
     Price,
     SortOrder.Descending
     ),
     Item_No = ThisItem.Item_No
    ).Price = Value(Label16_12.Text)

    and if you want to show only the first three items when the checkbox is checked by the user

    With(
     {
     _Data: 
     Filter(
     Transaction,
     Email = User().Email
     )
     },
     If(
     Checkbox3.Value,
     FirstN(
     SortByColumns(
     _Data,
     "Price",
     SortOrder.Descending
     ),
     3
     ),
     SortByColumns(
     _Data,
     "DateTime",
     SortOrder.Descending
     )
     )
    )

     

  • Iantaylor2050 Profile Picture
    531 on at

    Hi @WarrenBelz 

     

    My intention is to show all the rows which has Topper label set, when checkbox is checked. 

     

    If the Topper label is shown for 10 items out of total 17, i need to show all 10 items when checkbox is checked. 

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @Iantaylor2050 ,

    You cannot filter a gallery based on an element within the same gallery (you will create a Circular Reference). I would normally use AddColumns here to try and get a true/false value, but you are looking up and sorting the same list, so I am wondering why are you bothering to do all of that on the label when the price in the record simply needs to equal the value in Label12_16.

  • Iantaylor2050 Profile Picture
    531 on at

    Hi @WarrenBelz 

     

    I have a SharePoint list named Transaction. This list has all the items purchased by users at certain price. Below is the screenshot for MyItems which shows only the items which i have purchased. 

     

     

    Iantaylor2050_0-1696988414289.png

    From the above screenshot, for item number 502, the topper label is being shown, because rest of the users have purchased that item at price lesser than $17.95. 

     

    If i want to view only the items where i am the topper as per above screenshot, based on the checkbox click, how do i do that?

     

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @Iantaylor2050 ,

    The key is where is Label12_16 - is it the price label in the gallery ? I am also confused as this code you posted on the Visible

    If(
     First(
     SortByColumns(
     Filter(
     Transaction,
     Item_No= ThisItem.Item_No
     ),
     "Price",
     SortOrder.Descending
     )
     ).Price = Value(Label16_12.Text),
     true,
     false
    )

    says the price (only one record as you have used First) needs to be equal to this label (so how are you getting the items that are less than it). I may have other questions after you explain all of this and the ultimate answer may be that it is not possible if everything is referring to other parts of the gallery.

     

  • Iantaylor2050 Profile Picture
    531 on at

    Hi @WarrenBelz 

     

    Yes Label16_12 is the price label in the gallery 

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @Iantaylor2050 ,

    So where does the $17.95 come from ? I am getting further unclear here as there are prices both above and below it in the gallery and your Gallery Items is sorting by Price descending, so why are the two bottom records not on top ?

    Also, you did not explain how the items less than $17.95 also had labels as your Visible code has the criteria that the price has to equal the value in that label (not less than or equal to as the label suggest).

    To try and summarise this, the only possible way you can do what you want is to duplicate the logic in the Visible of those labels using AddColumns in the gallery Items then filtering these Items by the added column. I am currently simply quite unclear on the logic you are using to determine when to show them.

    Please have a think about this as to how you would describe their visibility (or not) in a few concise points.

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard