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
mlim0806
Frequent Visitor

If then statement using distinct counts

Hello, 

 

I have a list of employee IDs that are each assigned a Hire flag of 'yes' or 'no'. I am trying to create a new measure that says.

 

IF Hire field equals 'yes' THEN distinct count of Employee IDs

 

I would like this displayed as a whole number. Appreciate the help!

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @mlim0806 

 

Presumably the Employee ID's are unique?  And therefore a 'distinct' count is just a count as the ID's are already distinct?

 

Download my example PBIX file

 

Try this

 

 

Measure = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', 'DataTable'[Hire] = "Yes"))

 

count-ids.png

 

But if ID's are repeated, you can get your Distinct Count with this measure

Distinct ID Count = CALCULATE(DISTINCTCOUNT('DataTable_2'[ID]), FILTER('DataTable_2', 'DataTable_2'[Hire]="yes"))

 

 

regards

 

Phil

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
PhilipTreacy
Super User
Super User

Hi @mlim0806 

 

Presumably the Employee ID's are unique?  And therefore a 'distinct' count is just a count as the ID's are already distinct?

 

Download my example PBIX file

 

Try this

 

 

Measure = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', 'DataTable'[Hire] = "Yes"))

 

count-ids.png

 

But if ID's are repeated, you can get your Distinct Count with this measure

Distinct ID Count = CALCULATE(DISTINCTCOUNT('DataTable_2'[ID]), FILTER('DataTable_2', 'DataTable_2'[Hire]="yes"))

 

 

regards

 

Phil

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Thank you! It was an instance where Employee ID's could be hired on multiple accounts, so I wanted to count distinct. This worked!

Hi @mlim0806 

 

Glad this worked.  Please mark my answer as the solution so that anyone else reading this knows the solution.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors