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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
lhughes1
New Member

Count employee with multiple assignments only one time

My data set has mixed granularity.

lhughes1_0-1605882832512.png

For salary calculations this is fine because I need to use all 3 lines.

For health, however, I only want to count the amount one time.

In Excel, I added a column to identify only the first line for each employee. Later, I used that column in the health calculations.

The formula I used was =IF(COUNTIF($B$3:B3,B3)=1,1,0)

Now I've migrated to a data model and need to add a similar calculated column.

What is the DAX translation for the Excel formula above?

Or is there a better way to accomplish this goal?

Thank you.

 

2 REPLIES 2
Anonymous
Not applicable

It's best to change the data model to something that follows Best Practices. If you do that, you'll have no problems with such calculcations. My suggestion is this. Create a dimension called Employee with columns Emp Number, Name, Health Premium. Then create a fact table Assignments with columns Emp Number, Assignment, FTE, Salary. Connect them with one-way filtering on Emp Number. All columns in fact tables should always be hidden and slicing should be only done via dimensions. Then create the required measures. [Total Health Premium] will be SUM( Employee[Health Premium] ). Easy. [Total Salary] will be SUM( Assignments[Salary] ). Easy again.

 

The secret to good end-user experience, fast and SIMPLE DAX lies in the model itself. If you have a bad model, you'll be always struggling with simple things and your DAX will be awful. Do you want that? No. I thought so 🙂

amitchandak
Super User
Super User

@lhughes1 , Try a measure like

countx(filter(summarize(Table[employee number],"_1", count(Table[Assignments])),[_1]>1),[employee number])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.