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

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
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.