# Average YTD Headcount with PowerPivot/DAX



## jdorby (Nov 15, 2018)

Hi Everyone,

I have a fact table that is filled with multiple departments, with multiple headcount types (full time, part time, contractors, etc), spanning several years, at the MONTH LEVEL.  Some of the months during the year can have 0 values as well. I am trying to write a formula that calculates the YTD Average HC and can't quite figure it out.  I have a Date Table linked to my data set.  

When calculating YTD Sales my formula works perfectly:
=Calculate([Actuals (OP2 Rate)],DATESYTD(calendar[date]))

where "Actuals (OP2 Rate)" =calculate(sum(Fact_OpexHC[Amount@OP2Rate]),Fact_OpexHC[Scenario] = "Actuals")

I thought just substituting Average or AverageX for Sum in the formula above would work, but it doesn't.  

The first three columns below, Child, MonthNameShort, and Total show the headcount by month in my data model.  What I want my Avg YTD HC calc to look like is the 4th column, Avg YTD HC, which I currently don't have in the model.  Any help is greatly appreciated!!  Thanks, Jim


ChildMonthNameShortTotal        Avg YTD HCS1110 - Salaried HeadsJan115.00S1110 - Salaried HeadsFeb119.00117.00S1110 - Salaried HeadsMar122.00118.67S1110 - Salaried HeadsApr126.00120.50S1110 - Salaried HeadsMay127.00121.80S1110 - Salaried HeadsJun129.00123.00S1110 - Salaried HeadsJul131.00124.14S1110 - Salaried HeadsAug131.00125.00S1110 - Salaried HeadsSep131.00125.67

<colgroup><col><col><col><col></colgroup><tbody>

</tbody>


----------



## Matt Allington (Nov 16, 2018)

How about you write a measure that adds all the totals YTD and dive by the number of months ytd


----------

