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 by dist...
Power Apps
Answered

Filter gallery by distinct values if countrows is greater than 0

(0) ShareShare
ReportReport
Posted on by 249

I have a PowerApp that shows metrics for work completed. I am currently using the following to show distinct work values (workCat) and then sorting on results, and this works.

 

 

Sort(
 Distinct(
 'DataSource',
 workCat.Value
 ).Result,
 Result
)

 

 

 

The problem is, I also see workCat records that are blank (I have a radiomenu that allows to choose by month). I would like to still show the distinct workCat, but only when CountRows(Filter(DataSource, month = viewMonth)) > 0. So if there was no workCat for the chosen month, that month would not show up in the gallery.

 

An example would be that if trickethelp (workCat) was zero for the month of February, then it would not show up when I select February in the radiomenu. 

 

 

Categories:
I have the same question (0)
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Can you post some pictures?

  • techtudoor Profile Picture
    249 on at

    Unfortunately for this one I can not. I can try to describe it better.

     

    DataSource:

     

    workCat                      Month

     

    trinketHelp                 January

    benchwork                  January

    benchwork                  February

    benchwork                  February

    assist                           January

    assist                           February

    assist                           March

     

     

    So if I wanted to see only work completed in February, I would select February and the Gallery should show benchmark with 2 instances and assist with 1 instance.

    I would like trinketHelp not to appear, since there was no trinketHelp work done in February. Currently though it does show up and has zero instances listed.

     

    workCat I need to be distinct. 

  • Verified answer
    v-albai-msft Profile Picture
    Microsoft Employee on at

    Hi @techtudoor ,
    Based on your information,I think you can try this formula:

    Sort(
    Distinct(Filter('DataSource',Month = SelectedMonth),workCat.Value).Result,
    Result)

    Just do distinct action based on filtered results.

    Best regards,

    Allen

  • techtudoor Profile Picture
    249 on at

    @v-albai-msft , thank you so much. I knew I had to be close with all the variations that I had tried. I had convinced myself that CountRows had to be included. This works GREAT!!!

     

    Thank you

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard