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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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