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
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
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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.