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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.