Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Interesting situation here.
Using averageX to claculate the last X months returns values that differ from the same calculations in Excel.
The dark blue line is the number being averaged.
The Light blue line is the resultant average.
The first result (last number in the visual...13.11), is dead on with the Excel result:
But the numbers diverge from that point on:
The number that is being averaged (M_ComplaintsPer1MEA) is the result of a series of measures.
Please Wax Poetic
Update: All columns and measures inolved are defined as decimal with 4 decimal places.
Solved! Go to Solution.
Hiya @Anonymous
While the June 2024 12-month average looks correct, the earlier averages look to be 11 month averages. Not sure whether the issue is measure definition or something else in the model.
Here is how I would write the Avg of previous 12 measure myself. This assumes you have a 'Date' table set up in the usual way with a "Year Month" or equivalent column:
Avg of previous 12 =
CALCULATE (
AVERAGEX (
VALUES ( 'Date'[Year Month] ),
[M_CompIaintsPerIMEA]
),
DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -12, MONTH )
)
Note: When fewer than 12 months are available, this measure will average the available months (can be modified to return blank instead).
Are you able to get something like this working?
PBIX attached.
Regards
Hiya @Anonymous
While the June 2024 12-month average looks correct, the earlier averages look to be 11 month averages. Not sure whether the issue is measure definition or something else in the model.
Here is how I would write the Avg of previous 12 measure myself. This assumes you have a 'Date' table set up in the usual way with a "Year Month" or equivalent column:
Avg of previous 12 =
CALCULATE (
AVERAGEX (
VALUES ( 'Date'[Year Month] ),
[M_CompIaintsPerIMEA]
),
DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -12, MONTH )
)
Note: When fewer than 12 months are available, this measure will average the available months (can be modified to return blank instead).
Are you able to get something like this working?
PBIX attached.
Regards
I tried your Dax and still eneded up with the same numbers. But when I read where you mention it appareaed to be the average of he last 11 instead of 12, I decided to change the -12 in my Dax to -13 and shazam!
Either my spreadsheet was doing a 13 month or Bi counts funny.
This worked for me as well! Thanks for sharing this.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
25 | |
10 | |
8 | |
6 | |
6 |
User | Count |
---|---|
30 | |
11 | |
11 | |
10 | |
6 |