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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tango1201
Frequent Visitor

Calculate Average Employee Headcount for a given day or month

I am attempting to calculate a YTD average of how many employees we have for a given day or month.  For example and if we had 1,000 employees in Jan and 1,200 in Feb, the Feb YTD average would be 1,100.  I found the below DAX (modified from this blog) to be useful in calculating the number of employess on a given day but am now struggling with measuring a YTD average for a given day.  Any help is appreciated.

Thanks

 

Employee Count =
SUMX (
GENERATE (
CALCULATETABLE (
SUMMARIZE (
EmployeeRosterHires,
EmployeeRosterHires[Hire Date],
EmployeeRosterHires[Termination Date],
"Rows", COUNTROWS ( EmployeeRosterHires )
),
ALL ( 'Date' )
),
INTERSECT (
DATESBETWEEN ( 'Date'[Date], EmployeeRosterHires[Hire Date], EmployeeRosterHires[Termination Date] ),
LASTDATE ( 'Date'[Date] )
)
),
[Rows]
)

1 ACCEPTED SOLUTION

Substituting AVERAGEX for SUMX  in the Employee Count formula rendered that for every employee, there was one employee on average.  There's a meme there somewhere, for sure.

However and being that this was my first post, I accidentally posted it twice under two differents subject tags.  The response I received from the other post proved correct and is as follows:

 

AVG Daily = AVERAGEX(ALLSELECTED('Calendar'),[Employee Count])

 Thanks for your help

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @tango1201,

 

Have you try to use averagex to replace the sumx function?

Employee average Count =
AVERAGEX(
GENERATE (
CALCULATETABLE (
SUMMARIZE (
EmployeeRosterHires,
EmployeeRosterHires[Hire Date],
EmployeeRosterHires[Termination Date],
"Rows", COUNTROWS ( EmployeeRosterHires )
),
ALL ( 'Date' )
),
INTERSECT (
DATESBETWEEN ( 'Date'[Date], EmployeeRosterHires[Hire Date], EmployeeRosterHires[Termination Date] ),
LASTDATE ( 'Date'[Date] )
)
),
[Rows]
)

 

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Substituting AVERAGEX for SUMX  in the Employee Count formula rendered that for every employee, there was one employee on average.  There's a meme there somewhere, for sure.

However and being that this was my first post, I accidentally posted it twice under two differents subject tags.  The response I received from the other post proved correct and is as follows:

 

AVG Daily = AVERAGEX(ALLSELECTED('Calendar'),[Employee Count])

 Thanks for your help

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors