Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

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

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

 

Please help me ๐Ÿ™

Thank you

  • I see so you want to exclude Zero values. 

    With that in mind try this:

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


    Test: (no except)

    With:

     

4 Replies

  • ValtteriN's avatar
    ValtteriN
    Icon for Community Champion rankCommunity Champion

    Hi,

    This should do what you want:

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

     

    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/
    • Anonymous's avatar
      Anonymous
      Not applicable

      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( 

      • ValtteriN's avatar
        ValtteriN
        Icon for Community Champion rankCommunity Champion

        I see so you want to exclude Zero values. 

        With that in mind try this:

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


        Test: (no except)

        With: