This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
Hi,
Can someone please confirm if if the AVERAGEX function enables the evaluation of expressions for each row in the data model table or the visual table.
The reason why I'm asking is because I'm validating the average headcount across 12 months in Excel and I'm getting back 11286 but in Power BI using AVERAGEX I'm getting back 11276.
My best guess is that its evaluating expressions within the data model table that I'm calculating headcount from because if it was evaulating from the visual table it will come back with the same figure presented in Excel.
Below I've included the DAX for Headcount and Avg. Headcount.
Headcount = CALCULATE(DISTINCTCOUNT(PersonDetails[PERSON NUMBER]),
FILTER(VALUES(PersonDetails[WORK RELATIONSHIP START DATE]), PersonDetails[WORK RELATIONSHIP START DATE] <=MAX(DimDates[Date])),
FILTER(VALUES(PersonDetails[TERMINATION DATE]), OR(PersonDetails[TERMINATION DATE] >=MAX(DimDates[Date]),ISBLANK(PersonDetails[TERMINATION DATE]))))+0
Avg. Headcount =
VAR v_dates = DATESINPERIOD(DimDates[Date], MAX(DimDates[Date]), -12, MONTH)
RETURN
AVERAGEX(v_dates, [Headcount])
@Anonymous Yes, AVERAGEX is going to evaluate the measure Headcount for every row in v_dates and then take the average of that. BTW, I certainly would not trust DATESINPERIOD like, at all. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000
@Greg_Deckler Thanks for confirming, but could you please suggest what I should use instead of DATESINPERIOD in my v_dates variable?
@Anonymous If it were me, I would do something like this:
Avg. Headcount =
VAR _MaxDate = MAX( 'DimDates'[Date] )
VAR _EOM12 = EOMONTH( _MaxDate, -12 )
VAR _MinDate = DATE( YEAR( _EOM12 ), MONTH( _EOM12 ), 1 )
VAR _v_dates = SELECTCOLUMNS( FILTER( 'DimDates'[Date], [Date] <= _MaxDate && [Date] >= _MinDate ), "Date", [Date] )
RETURN
AVERAGEX( v_dates, [Headcount] )
More verbose but you can debug it if something is amiss.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 25 | |
| 20 | |
| 16 |
| User | Count |
|---|---|
| 61 | |
| 49 | |
| 28 | |
| 23 | |
| 23 |