Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Count filtered rows

GOAL: I would like to count the number of outlets which sent more than 100 messages.

 

DATA: In my dataset, I have OutletIDs and MessageIDs (called MessageOid) of messages that were sent per outlet.

Natalie123455_0-1689623812449.png

 

As you can see/count in the table above, Outlet 008 sent 17 distinct messages. The table below again reflects this: It counts the disctint message IDs per outlet to find out how many messages where sent per outlet.

 

Natalie123455_1-1689623811719.png

 

PROBLEM

Now, I would like to display the amount of outlets which sent over 100 messages. For example, Outlet 02 is one such outlet (it sent 1440 messages) - Outlet 008 is NOT such outlet (it sent only 17 messages).

 

SUGGESTED SOLUTION

@v-tangjie-msft suggested using the following measure

CountMeasure =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Outletld] ),
    FILTER (
        'Table',
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[MessageOid] ),
            FILTER ( 'Table', 'Table'[Outletld] = EARLIER ( 'Table'[Outletld] ) )
        ) > 100
    )
)

 

The measure does the job - thanks a lot, @v-tangjie-msft! However, it takes very long to run - sometimes it fails and displays this error message:

Natalie123455_2-1689625137864.png

 

Is there any way to change this measure so it becomes more efficient and faster? Many thanks for any help in advance!

Best, Natalie

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Do these measures work any faster?

Message count = DISTINCTCOUNT('Table'[MessageOid])
Measure = COUNTROWS(FILTER(VALUES('Table'[Outletld]),[Message count]>100))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Do these measures work any faster?

Message count = DISTINCTCOUNT('Table'[MessageOid])
Measure = COUNTROWS(FILTER(VALUES('Table'[Outletld]),[Message count]>100))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

That's brilliant! A short, easy-to-understand measure! I tried very similar measures which didn't work - now, I know what I missed. Many thanks for your help!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.