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
bitbit
Helper I
Helper I

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 9
Anonymous
Not applicable

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

I did, but still get syntax error.

Anonymous
Not applicable

Please share few rows of actual dataset ?

As requested:

OCVersionPeriodGroupLineData
ChinaPrior Year1TotalTotal direct manufacturing personnel76
ChinaPrior Year2TotalTotal direct manufacturing personnel73
ChinaPrior Year3TotalTotal direct manufacturing personnel70
ChinaPrior Year4TotalTotal direct manufacturing personnel67
ChinaPrior Year5TotalTotal direct manufacturing personnel66
ChinaPrior Year6TotalTotal direct manufacturing personnel66
ChinaPrior Year7TotalTotal direct manufacturing personnel67
ChinaPrior Year8TotalTotal direct manufacturing personnel69
ChinaPrior Year9TotalTotal direct manufacturing personnel72
ChinaPrior Year10TotalTotal direct manufacturing personnel80
ChinaPrior Year11TotalTotal direct manufacturing personnel82
ChinaPrior Year12TotalTotal direct manufacturing personnel81
ChinaBudget1TotalTotal direct manufacturing personnel87
ChinaBudget2TotalTotal direct manufacturing personnel81
ChinaBudget3TotalTotal direct manufacturing personnel80
ChinaBudget4TotalTotal direct manufacturing personnel77
ChinaBudget5TotalTotal direct manufacturing personnel75
ChinaBudget6TotalTotal direct manufacturing personnel74
ChinaBudget7TotalTotal direct manufacturing personnel72
ChinaBudget8TotalTotal direct manufacturing personnel75
ChinaBudget9TotalTotal direct manufacturing personnel87
ChinaBudget10TotalTotal direct manufacturing personnel89
ChinaBudget11TotalTotal direct manufacturing personnel91
ChinaBudget12TotalTotal direct manufacturing personnel94
ChinaActual1TotalTotal direct manufacturing personnel76
ChinaActual2TotalTotal direct manufacturing personnel68
ChinaActual3TotalTotal direct manufacturing personnel67
ChinaActual4TotalTotal direct manufacturing personnel66
ChinaActual5TotalTotal direct manufacturing personnel63
ChinaActual6TotalTotal direct manufacturing personnel63
ChinaPrior Year1internalTotal direct manufacturing personnel58
ChinaPrior Year2internalTotal direct manufacturing personnel58
ChinaPrior Year3internalTotal direct manufacturing personnel57
ChinaPrior Year4internalTotal direct manufacturing personnel57
ChinaPrior Year5internalTotal direct manufacturing personnel56
ChinaPrior Year6internalTotal direct manufacturing personnel56
ChinaPrior Year7internalTotal direct manufacturing personnel56
ChinaPrior Year8internalTotal direct manufacturing personnel55
ChinaPrior Year9internalTotal direct manufacturing personnel55
ChinaPrior Year10internalTotal direct manufacturing personnel55
ChinaPrior Year11internalTotal direct manufacturing personnel55
ChinaPrior Year12internalTotal direct manufacturing personnel55
ChinaBudget1internalTotal direct manufacturing personnel66
ChinaBudget2internalTotal direct manufacturing personnel66
ChinaBudget3internalTotal direct manufacturing personnel66
ChinaBudget4internalTotal direct manufacturing personnel64
ChinaBudget5internalTotal direct manufacturing personnel65
ChinaBudget6internalTotal direct manufacturing personnel64
ChinaBudget7internalTotal direct manufacturing personnel65
ChinaBudget8internalTotal direct manufacturing personnel65
ChinaBudget9internalTotal direct manufacturing personnel66
ChinaBudget10internalTotal direct manufacturing personnel66
ChinaBudget11internalTotal direct manufacturing personnel69
ChinaBudget12internalTotal direct manufacturing personnel69
ChinaActual1internalTotal direct manufacturing personnel57
ChinaActual2internalTotal direct manufacturing personnel56
ChinaActual3internalTotal direct manufacturing personnel56
ChinaActual4internalTotal direct manufacturing personnel56
ChinaActual5internalTotal direct manufacturing personnel55
ChinaActual6internalTotal direct manufacturing personnel55

Hi,

There is no Year and/or Date column.  How can one use any Date Intelligence functions on this dataset.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

The "Period" column refers to the month in abbrev.  eg. 1 = Jan.

Hi,

Yes, i see that but there is still no Year column there so i cannot generate a Date column.  It will be ideal if you have a Date column but if you do not then i can still live with 2 seperate columns - one for Year and another for Month.  From these 2 columns, i can generate the Date column.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi 

Are you looking for Average as below.

Just to make sure if my understanding of your problem is right.

 

1.png

 

 

Yes, the formula should also calculate the average according to the selected month(2).  eg. average for Jan-Mar for actual, budget and prior year.

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.