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

View all the Fabric Data Days sessions on demand. View schedule

Reply
jcru1999
Frequent Visitor

Average Headcount for multiple Years and Year to Date

Hi Community, 

We are trying to get an average for a headcount for past completed years and YTD for 2023. Our headcount data set is an append from monthly headcounts as of the first of each month. We when we display the information using our DIM date table, we get the average number, but we are searching a measurement as our final objective is to measure turnover (Average headcount of a year/Total departures in a year). 

 

Here is a sample of how the data set looks:

Original_Hire_DateOfficeLength_of_Service_in_Months_from_Continuous_Service_DateEmployee_TypeWorker_ActiveCost_CenterEmployee_IDHire_DateProvinceEffective DateMonthlyHeadcountColumnYear
01-Jan-05Barrie174Director1AR592001-Jan-05Ontario01-Jul-1912019
01-Jan-05Barrie157Director1AR592001-Jan-05Ontario01-Feb-1812018
01-Jan-08Barrie138Director1AR7197701-Jan-08Ontario01-Jul-1912019
01-Jan-08Barrie121Director1AR7197701-Jan-08Ontario01-Feb-1812018
05-Sep-07Barrie141Director1AR501605-Sep-07Ontario01-Jul-1912019
09-Dec-96Barrie270Employee1Fin184509-Dec-96Ontario01-Jul-1912019
09-Dec-96Barrie253Employee1Fin184509-Dec-96Ontario01-Feb-1812018
04-Sep-07Toronto141Employee1HR505704-Sep-07Ontario01-Jul-1912019
04-Sep-07Toronto124Employee1HR505704-Sep-07Ontario01-Feb-1812018
07-Aug-07Toronto142Employee1HR518607-Aug-07Ontario01-Jul-1912019
07-Aug-07Toronto125Employee1HR518607-Aug-07Ontario01-Feb-1812018

"""Here is the measure that we were trying to use:

AverageHeadcountYTD2023 =
CALCULATE(
    AVERAGE('LD Headcount'[MonthlyHeadcountColumn]),
    DATESYTD('LD Headcount'[Effective Date], DATE(2023, 12, 31))
)

This dax gives the follwign error: "Only constant date value is allowed as a year end date argument."

 

AverageHeadcountYTD2023 =
VAR MaxDate = MAX('LD Headcount'[Effective Date])
RETURN
    CALCULATE(
        AVERAGE('LD Headcount'[MonthlyHeadcountColumn]),
        'LD Headcount'[Effective Date] <= MaxDate,
        YEAR('LD Headcount'[Effective Date]) = 2023
    )

This gives the following error: This was just calculating for 2023 and was returning a value of 1 for 2023

 

Then we tried the following formula: 

AverageHeadcountYTD2023 =
VAR MaxYear = YEAR(TODAY())
RETURN
    SUMMARIZE(
        FILTER(
            'LD Headcount',
            YEAR('LD Headcount'[Effective Date]) <= MaxYear
        ),
        'LD Headcount'[Year],
        "AverageHeadcount",
        AVERAGE('LD Headcount'[MonthlyHeadcountColumn])
    )"""

 This gave us the error: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

What are we doing wrong, or do you have any tips or tricks that coudl help us achieve the Year and Year to Date average in a measure?

 

@amitchandak

1 REPLY 1
Anonymous
Not applicable

Hi @jcru1999 ,

You can update the formula of your measure [AverageHeadcountYTD2023] as below:

AverageHeadcountYTD2023 =
CALCULATE (
    AVERAGE ( 'LD Headcount'[MonthlyHeadcountColumn] ),
    FILTER (
        'LD Headcount',
        YEAR ( 'LD Headcount'[Effective Date] ) <= YEAR ( TODAY () )
    )
)

If the above measure can't give you the correct result, could you please provide your expected result base on your provided data? Thank you.

Best Regards

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors