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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
JULY1
Helper I
Helper I

How to count all duplicate and single values

Hi,

 

I would like to count the number of employee by department, and I use this formula

Attrition HC 2 = CALCULATE( COUNTROWS(except(values(Terminate[ID]),VALUES(Zero[Employee ID]))),Reasons_LookUp[Involuntary/Voluntary]="Voluntary")

 

Following is the example of the table Terminate[ID]

Employee IDDepartmentStatus
12345FinanceVoluntary
12345FinanceVoluntary
23456Account Voluntary
34567Human ResourcesVoluntary
45678SalesInVoluntary

 

Following is the example of the table Zero[Employee ID]

Employee IDDepartment
99999Marketing
88888Marketing

 

 

However, the result i got is

JULY1_2-1696913852680.png

Which it should actually be 2 in finance and the total should be 4.

 

Please help me 🙏

Thank you

1 ACCEPTED SOLUTION

I see so you want to exclude Zero values. 

With that in mind try this:

ValtteriN_0-1696926123096.png

Measure = CALCULATE(COUNT('Table (2)'[Employee ID]),'Table (2)'[Status]="Voluntary",EXCEPT(VALUES('Table (2)'[Employee ID]),VALUES('Zero'[EID])))


Test: (no except)

ValtteriN_2-1696926280623.png

With:

ValtteriN_3-1696926336444.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
ValtteriN
Super User
Super User

Hi,

This should do what you want:

Measure = CALCULATE(COUNT('Table (2)'[Employee ID]),'Table (2)'[Status]="Voluntary")

ValtteriN_0-1696915883601.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

 

Thank you for your answer.
However, in my full data set, there are the employee ID in 'Terminate' table that can match with the 'Zero' table so I still need to contain  (except(values( 

I see so you want to exclude Zero values. 

With that in mind try this:

ValtteriN_0-1696926123096.png

Measure = CALCULATE(COUNT('Table (2)'[Employee ID]),'Table (2)'[Status]="Voluntary",EXCEPT(VALUES('Table (2)'[Employee ID]),VALUES('Zero'[EID])))


Test: (no except)

ValtteriN_2-1696926280623.png

With:

ValtteriN_3-1696926336444.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




It works!

Thank you so muchhh.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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