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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. 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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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