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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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

hi @user900 

sorry it is a typo, it is VAR

View solution in original post

8 REPLIES 8
FreemanZ
Super User
Super User

hi @user900 

 

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

yes

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?

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.

hi @user900 

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

Works perfectly.  Thank you so much!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.