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
Anonymous
Not applicable

How to do distinct employee count by distinct ID

I have 2 formulas that make up this chart:

1.PNG

 

And they are:
1.PNG
1.PNG

The 'Employee Range Size' is being used as the Legend and the values are a distinct count on the company ID. I also have this same information separated into tables such as:

1.PNG

So the 124 is doing a distinct count on the company ID which is what I want. My issue is the Employee Count column. My total at the bottom for that column is a bit skewed because as you can see for company ID 0340, it is listed twice because it has a payroll service and a cbiz ems service, so instead of just counting 214 once, it is doubling it to 428. How can I set this up to only count 214 one time? For whatever reason when I remove the 'Service' Column from the table, the grand total goes up almost 20,000 for some reason I don't understand, so that is not the solution. If there is a better way to set all of this up, I am open to any suggestions Smiley Happy.

4 REPLIES 4
v-xjiin-msft
Solution Sage
Solution Sage

@Anonymous

 

In your scenario, there exists duplicated Employee Count for each Company ID because of the Service. When you put Employee Count field in the Values of a Pie Chart, the duplicated has been summed automatically. And you don’t want the duplicated be summed. Right?

 

First, your expressions for Employee Counts and Employee Range Size are both right. The reason for your issue is that charts cannot distinguish if the values are duplicated. By default it will sum them all automatically. To modify this, you just need to change the aggregate function for Employee Count from Sum to Max.

 

1111.png2222.png

Thanks,
Xi Jin.

Anonymous
Not applicable

Mine doesn't look like it's set up the same way. My 'Employee Counts' is a measure I created specifically for counting the number of times an employee id appears for a company id. I do not have the option to change this to Maximum. On my chart My Legend is "Employee Range Size" and I'm just using a distinct count on the company ID as my values to capture how many companies fall within each range. Here are the pieces:

1.PNG

 

Then for the corresponding tables, these are the attached pieces:
1.PNG

 

So the 'Employee Count' column you see on each table is just the ID field from the Employees table and is doing a Count on that column:

1.PNG

 

And I have filters on each table referencing my 'Employee Counts' measure I created so it returns the same values represented on my graph:

1.PNG

1.PNG

Greg_Deckler
Super User
Super User

You have a classic "My Measure Total is Wrong" situation:

 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thank you smoupre! However, I am still unsure of how to apply that logic to my situation. Is there any way to have the table read all the company ID's within that table and count the Employee Count for the given Company ID just once?

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.