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 August 31st. Request your voucher.

Reply
jpaguiar79
New Member

Distinctcount in a column based on the other column

Hello community,

I have a table with these columns below and need to know how many unique employees per qty of hours.

jpaguiar79_0-1699556617782.png

 

Result should be: 3 employees with 189 hours (A, B, C) and 2 employees with 168 hours (D, E).

 

This is already a filtered table (by country). Field "hours" is a measure.

 

I tried Distinctcount with filter, countrows, etc.

 

THANKS!

1 ACCEPTED SOLUTION
jpaguiar79
New Member

Solution:

 

VAR _ctmax = CALCULATE(DISTINCTCOUNT('table1'[employee]),FILTER('table1','table1'[hours] = 189))

VAR _ctmin = CALCULATE(DISTINCTCOUNT('table1'[employee]),FILTER('table1','table1'[hours] = 168))

 

And I put 189 and 168 into another VARs before these sentences to make sure I get max and min.
Thanks!

View solution in original post

1 REPLY 1
jpaguiar79
New Member

Solution:

 

VAR _ctmax = CALCULATE(DISTINCTCOUNT('table1'[employee]),FILTER('table1','table1'[hours] = 189))

VAR _ctmin = CALCULATE(DISTINCTCOUNT('table1'[employee]),FILTER('table1','table1'[hours] = 168))

 

And I put 189 and 168 into another VARs before these sentences to make sure I get max and min.
Thanks!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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