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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
kkashiv
Frequent Visitor

Missing months from DAX expression for a Measure

I have written this DAX expression for a measure in order to find the 12 month rolling average starting from the most recent month to 12 months before. 

 

12MonthRollingAvg =
VAR numOfMonths=12
VAR lastCurrentDate=MAX('Calendar_Month'[First Day of Month])
VAR Period = DATESINPERIOD('Calendar_Month'[First Day of Month], lastCurrentDate,-numOfMonths,MONTH)
VAR result = CALCULATE(
    AVERAGEX(
        VALUES('Calendar_Month'[Calendar Month - Name]), [Measure_2]),
        Period
)
Return
if ([Measure_2]>0 , result)
 
 
I have data from 2018 to 2023 coming from an SSAS connection. The visualization with this measure is posted below:
kkashiv_0-1695397877415.png

This is the most recent month in the table i.e. September.
However the first month displays February whereas it should have been October i.e. October to September. 

kkashiv_1-1695398110780.png

 



I'm unsure as to why this is happening as the data is precise for all months from 2018-2023. Would appreciate any help.

1 REPLY 1
some_bih
Super User
Super User

Hi @kkashiv I would say your measure for Average do not include unique values for periods as in 12 months period there is "2 years" included, like 3 months from previous year and 9 months in this year. I mean, you should include your Calendar date, columns like YEAR-MONTH, not just month. Try it and debug.

Great link with example is below

https://www.sqlbi.com/articles/rolling-12-months-average-in-dax/ 

Hope this help. Cudos appreciated.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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