cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors