cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
user900
Helper I
Helper I

Distinct Count across all departments

For distinct count of employees, I'm using the following measure in a card:

calculate(DISTINCTCOUNT('Table'[Emp ID])
In addition to this, I need to show a breakdown by department, but when I use the same measure with department on the x-axis, the count is higher. I think it's because one employee could appear in multiple departments due to transferring sometime throughout the year.  
Is there a way to get distinct count of employee ID across all departments?
 
Please and thanks
1 ACCEPTED SOLUTION
FreemanZ
Community Champion
Community Champion

hi @user900 

sorry it is a typo, it is VAR

View solution in original post

8 REPLIES 8
FreemanZ
Community Champion
Community Champion

hi @user900 

 

do you mean count an employee at the last department only?

yes

FreemanZ
Community Champion
Community Champion

hi @user900 

try like:

Count =
VAR _table1 =
ADDCOLUMNS(
    SUMMARIZE(
         TableName,
         TableName[EmpID],
         TableName[Department]
    ),
    "Date",
    CALCULATE(MAX(TableName[Date]))
)
VAT _table2 =
TREATAS(
     _table1,
    TableName[EmpID],
    TableName[Department],
    TableName[Date]
)
RETURN
COUNTROWS(_table2)
 
in case of issue, please consider paste some sample data and @me

I applied as you suggested.

I'm not familiar with VAT so I don't know how to troubleshoot this error: The syntax for 'VAT_table2' is incorrect.   Can you help?

FreemanZ
Community Champion
Community Champion

hi @user900 

sorry it is a typo, it is VAR

One more question.  Of that same population broken down by department, can I add a filter?  I also need to show whether the employee passed or failed a course.

FreemanZ
Community Champion
Community Champion

hi @user900 

Filtering on other dimension shall still work. Just try and let us know. 

Works perfectly.  Thank you so much!

Helpful resources

Announcements
T-Shirt Design Challenge 2023

Power BI T-Shirt Design Challenge 2023

Submit your creative T-shirt design ideas starting March 7 through March 21, 2023.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors