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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
dev85
Frequent Visitor

Distinct count grouping measure

Hello guys!

 

I have the next table

 

Client nameCompliance
AYES
AYES
BNO
CYES
DYES
EYES
EYES
ANO

I need to set up a measure with a distinc count on the client names based on the compliance value, this means that only count a client if all the grouped compliance answers are = "Yes". For example, for this case the result is 3 because only C, D and E compliances are all "Yes", A and B are not counted because the only reply for B is "No" and for A, one of the submits is also "No".

 

Thanks in advance for the help!

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @dev85 

 

You can try the following methods.

Measure =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Client name] ),
    FILTER (
        ALL ( 'Table' ),
        CALCULATE (
            MIN ( 'Table'[Compliance] ),
            ALLEXCEPT ( 'Table', 'Table'[Client name] )
        ) = "YES"
    )
)

vzhangti_0-1668672312582.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @dev85 

 

You can try the following methods.

Measure =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Client name] ),
    FILTER (
        ALL ( 'Table' ),
        CALCULATE (
            MIN ( 'Table'[Compliance] ),
            ALLEXCEPT ( 'Table', 'Table'[Client name] )
        ) = "YES"
    )
)

vzhangti_0-1668672312582.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

It worked perfectly! I just remove the ALL function because I needed for the measure to be dynamic according to the page filters. 
Thank you so much!

Greg_Deckler
Community Champion
Community Champion

@dev85 Maybe:

Measure =
  VAR __YesTable = DISTINCT(SELECTCOLUMNS(FILTER('Table',[Compliance] = "YES"),"__Client",[Client name]))
  VAR __NoTable = DISTINCT(SELECTCOLUMNS(FILTER('Table',[Compliance] = "NO"),"__Client",[Client name]))
  VAR __Table = EXCEPT(__YesTable, __NoTable)
  VAR __Result = COUNTROWS(__Table)
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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