Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

DAX average formula with filter

My dataset captures the following:

CountryVersionMonthClassificationLineData
ChinaActualJanTotalDirect labour headcount 
ChinaActualFebTotalDirect labour headcount 
ChinaBudgetseparate lines for all 12 monthsTotalDirect labour headcount 
ChinaPrior Yearseparate lines for all 12 monthsTotalDirect labour headcount 
ChinaActualJanInternalDirect labour headcount 
ChinaBudgetseparate lines for all 12 months InternalDirect labour headcount 
ChinaPrior Yearseparate lines for all 12 monthsInternalDirect labour headcount 
ChinaActualetcTotalS&M headcount 
ChinaBudgetetcTotalS&M headcount 
ChinaPrior YearetcTotalS&M headcount 
etc     

 

I tried unsuccessfully to create a DAX formula to calculate the average headcount filtered according to country, month, classification and headcount group:

AvgDL = CALCULATE(AVERAGE('Table'[Data]), FILTER(ALLSELECTED(Table), Table[Line] = "Total direct labour", Table[Classification]="FTE Total",Table[Country],Table[Date] ) ) )
 
Pls advise how to correct this formula.

9 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    It looks like you are trying to Average a subset of data and so you should use AVERAGEX formula.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I did, but still get syntax error.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Please share few rows of actual dataset ?