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 / Filter Gallery on clic...
Power Apps
Suggested Answer

Filter Gallery on click of Button & show count and change status as per dates added

(0) ShareShare
ReportReport
Posted on by 697
Hello,
 
1st Requirement:
I have a Gallery named as galInspection. I'm looking for a solution, where when we click on a specific button the gallery should filter accordingly and show their count
 
For Instance - I have 4 buttons on my screen and 1 field called as Status column.
 
1. Button 1
2. Button 2
3. Button 3
4. Button 4
 
For example: I have total 24 records in my Gallery (which will show all this 24 records when none of the buttons are clicked or we have cleared the Gallery)
 
Show the count on below 6 fields:
 
1. start_date has 3 blank records
2 and 3. end_date & due_date has 5 blank records
4. birth_date has 7 blank records
5 and 6. order_date & billed_date has 9 blank records
 
Now when we click on Button 1, in this button the value should show as 3 and gallery should filter accordingly with 3 records (only blanks to be filtered...were we do not have start_dates)
 
Similarly when we click on Button 2, in this button the value should show as 5 and gallery should filter accordingly with 5 records (only blanks to be filtered...were we do not have end_date & due_date) and so on for field 4, 5 and 6.
 
2nd Requirement when dates are added change the status :
 
When start_date (DataCardValue15) is added, the status should change to R1
When end_date & due_date (DataCardValue19 and 18) is added, the status should change to R2
When birth_date (DataCardValue8) is added, the status should change to R3
When order_date & billed_date (DataCardValue21 and 22) is added, the status should change to R4
 
Please advise.
Categories:
I have the same question (0)
  • Suggested answer
    Kalathiya Profile Picture
    1,669 Super User 2026 Season 1 on at
    Hello @Prem4253
     
    Requirement 1: Filter Gallery Based on Button Click and Show Counts
     
    Filtering the Gallery Based on Button Click and Showing Counts
     
    Step 1: Create variables for filtering
    We will use a variable to track which button is clicked. For example, varFilter.
    Set the OnSelect property of each button:
    // Button 1 (Start Date blanks)
    Set(varFilter, "Start");
    
    // Button 2 (End Date & Due Date blanks)
    Set(varFilter, "EndDue");
    
    // Button 3 (Birth Date blanks)
    Set(varFilter, "Birth");
    
    // Button 4 (Order Date & Billed Date blanks)
    Set(varFilter, "OrderBilled");
    
    Steps 2: Filter the gallery
    Set the Items property of your gallery galInspection like this:
    If(
        IsBlank(varFilter), 
        YourDataSource, // no filter
        varFilter = "Start", Filter(YourDataSource, start_date = Blank()),
        varFilter = "EndDue", Filter(YourDataSource, end_date = Blank() && due_date = Blank()),
        varFilter = "Birth", Filter(YourDataSource, birth_date = Blank()),
        varFilter = "OrderBilled", Filter(YourDataSource, order_date = Blank() && billed_date = Blank())
    )
    
    Step 3: Show counts on the buttons
    Set the Text property of each button to show the count:
    // Start Date
    CountRows(Filter(YourDataSource, start_date = Blank()))
    
    // End & Due Date
    CountRows(Filter(YourDataSource, end_date = Blank() && due_date = Blank()))
    
    // Birth Date
    CountRows(Filter(YourDataSource, birth_date = Blank()))
    
    // Order & Billed Date
    CountRows(Filter(YourDataSource, order_date = Blank() && billed_date = Blank()))
    
     
    📩 Need more help? Mention me anytime!
    ✔️ Don’t forget to Accept as Solution if this guidance worked for you.
    💛 Your Like motivates me to keep helping!
     
  • Prem4253 Profile Picture
    697 on at
     
    I'm reposting my requirement once again. Appreciate if you could support again.
     
    I will have 4 buttons in the form in which I should get counts of blank records for below labelled buttons
     
    We should get below Overall Counts referring Status Column without filtering Class Type column
     
     
    Secondly we will insert 2 more buttons based on Class Type column i.e. First Class and Business Class
     
    When First Class button clicked, Filter the data based on Class Type column and give the Counts of Blank Dates referring Verification Date, ROI Date 1, ROI Date 2 and ROI Date 3 columns
     
     
    In this case all the counts will remain the same, because Business Class type will only add Verification Date, other Dates are not applicable for them to enter
     
    So when First Class button is clicked the count will be 7, 20, 27 and 10
     
    And when Business Class button is clicked, count will be 0, 0, 0 and 0. Business Class does not has any blank dates in Verification Date column, so the count returns as 0.
     
    I have already built up some logics, as per my knowledge and your last post but the counts are not matching.
     
    Please advise further.
  • Kalathiya Profile Picture
    1,669 Super User 2026 Season 1 on at
    Hello @Prem4253
     
    1. Setting the Variable for Class Type
    You can use a context variable to store the selected Class Type when the user clicks on either the "First Class" or "Business Class" button. Set the OnSelect property of each class type button:
     
    First Class Button
    Set(varClassType, "First Class")
    
    Business Class Button
    Set(varClassType, "Business Class")
    Using the Variable to Filter and Count Blanks
    If(
        IsBlank(varFilter), 
        YourDataSource, // no filter
        varFilter = "Start", Filter(YourDataSource, start_date = Blank() && ClassType = varClassType),
        varFilter = "EndDue", Filter(YourDataSource, end_date = Blank() && due_date = Blank() && ClassType = varClassType),
        varFilter = "Birth", Filter(YourDataSource, birth_date = Blank() && ClassType = varClassType),
        varFilter = "OrderBilled", Filter(YourDataSource, order_date = Blank() && billed_date = Blank() && ClassType = varClassType)
    )
    Show counts on the buttons
    Set the Text property of each button to show the count:
    // Start Date
    CountRows(Filter(YourDataSource, start_date = Blank() && ClassType = varClassType))
    
    // End & Due Date
    CountRows(Filter(YourDataSource, end_date = Blank() && due_date = Blank() && ClassType = varClassType ))
    
    // Birth Date
    CountRows(Filter(YourDataSource, birth_date = Blank() && ClassType = varClassType ))
    
    // Order & Billed Date
    CountRows(Filter(YourDataSource, order_date = Blank() && billed_date = Blank() && ClassType = varClassType))
    Tab code will be same. 
  • Prem4253 Profile Picture
    697 on at
     
    Thanks!
     
    By the time I try with the logics provided by you in your last post, can you please confirm if you have referred to the excel that I had attached and the counts matches with the excel data ?
     
    My Apologize, In my initial post the headers that I mentioned were different from the one I posted in my last post.
     
    Appreciate for looking onto this :)
  • Kalathiya Profile Picture
    1,669 Super User 2026 Season 1 on at
    Hello @Prem4253

    In both cases, I’ve already provided a clear and detailed explanation of the underlying logic. At this point, you simply need to replace the sample data sources and column names with the ones used in your actual model. The structure of the solution remains the same, only the field references should be updated based on your environment.

    The core concept has been fully shared, so it’s now a matter of applying it consistently to your own tables and columns.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 493 Most Valuable Professional

#2
11manish Profile Picture

11manish 479

#3
Haque Profile Picture

Haque 328

Last 30 days Overall leaderboard