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

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
Exciting changes

Power BI Community Changes

Check out the changes to the Power BI Community announced at Build.

May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Kudo Data Story carousel

Data Stories Gallery

Visit our Data Stories Gallery and give kudos to your favorite Data Stories.

Top Solution Authors