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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.