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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Headcount DAX Formula

Hello,

I am new to Power BI and need your precious help here.

My data is as follows:

ArianeL_0-1674718650145.png

My calendar is as follows:

ArianeL_1-1674718721012.png

 

What is the formula for headcount per month please?

I am trying this but it is not functioning..

 

Headcount = CALCULATE(DISTINCTCOUNT(Employees[EmployeeID]),FILTER(Employees,and(Employees[DateStart]<=[Selected date],OR(Employees[DateDeparture]=BLANK(),Employees[DateDeparture]>[Selected date]))))
 

Thank you so much for your assistance

Ariane

6 REPLIES 6
Anonymous
Not applicable

IT'S GOOD! 

ArianeL_0-1674736842518.png

 

Thank you so much @johnt75 ! You rock! 😃💪

johnt75
Super User
Super User

Try

Headcount =
VAR SelectedDate =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Employees[EmployeeID] ),
        Employees[DateStart] <= SelectedDate
            && (
                ISBLANK ( Employees[DateDeparture] )
                    || Employees[DateDeparture] > SelectedDate
            )
    )
Anonymous
Not applicable

Hello,

I am having this error

ArianeL_0-1674732125772.png

Cannot find the table 'Date'. 

Thank you for your help

Change 'Date'[Date] to 'Calendar'[Date]

Anonymous
Not applicable

It is still not good 😕

From my excel I have 182 employees in Dec 2022 but the headcount showing 229.

It is still taking employees who left in 2021

Anonymous
Not applicable

Looks like I found the mistake.

The departure date should have been put in all the months of the employees who left. I had included it only in the month they left. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.