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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

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.

Anonymous
Not applicable

I did, but still get syntax error.

Anonymous
Not applicable

Please share few rows of actual dataset ?

Anonymous
Not applicable

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

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

 

 

Anonymous
Not applicable

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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