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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure that distinct counts based on other columns

Hello, everyone! 

 

My table follows this structure:

ID  ClassCQ
111  T00.2
111  T00.2
111  K00.2
222  P00.2
222L800.2
333  R1  00.2
444  H  00.1  
444  K  00.1  

 

As you can see, the values in "ID" column can have more than one occurence for each ID (can be repeated). I want to create a measure that counts all the following DISTINCT IDs values:

If Class = H or K or R1

So if a certain ID has at least one occurrence in Class column thats = H or K or R1 the measure will count it.


For the example table above, the count measure should show me 3, cause theres 3 IDs in the table that had a least 1 ocurrence of H, K or R1 in the Class column (111, 333 and  444)

Can someone help me?

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @Anonymous ,

 

this measure

Measure 2 = 
/* H, K, R1 */
CALCULATE(
    DISTINCTCOUNT('Table (3)'[ID  ])
    , 'Table (3)'[Class] in {"H" , "K" , "R1"}
)

retruns 3.

 

Hopefully, this is what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

12 REPLIES 12

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.