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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Natalie123455
Frequent Visitor

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/

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.