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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
dmalviya
Frequent Visitor

Issue with 12 Month Moving Average Calculation - Need Help

Hi,

 

i am facing issue while calculating 12 month moving average.  I am using below formulas -

 

Number of periods =
CALCULATE (
    CALCULATE ( COUNTROWS ( VALUES ( DimDate[MonthName] ) )),
    DATESBETWEEN (
        DimDate[Date],
        NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( DimDate[Date] ) ) ),
        LASTDATE ( DimDate[Date] )
    )
)

 

--------------------------------------------------------------------------------------

12 Month Sales Moving Average =
CALCULATE (
    [TotalVolume],
    DATESBETWEEN (
        DimDate[Date],
        NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( DimDate[Date].[Date] ) ) ),
        LASTDATE ( DimDate[Date].[Date] )
    )
)
    / [Number of periods]

 

-------------------------------------------

 

the above formula is working correctly. But there is one issue. Sales table is missing some months transaction. Like there is no transaction for October, November & December 2018 month but still graph shows [12 Month Moving Average] for these months.

Similarly few months are missing from January to September also but value is coming.

 

My requirement is that graph should show [12 Month Moving Average] for the months for which transactions available.

 

DimDate is monthly & generated for full 2017 & 2018 year. All months are covered.

Sales table has sales data but some months are missing.

Issue.PNG

 

 

Now you see on above picture some value is coming as Blank & also value for October, November & Deceber 2018. But there is no transaction for these months.

 

Please suggest how to fix this issue.

 

 

1 REPLY 1
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @dmalviya

 

You may try to remove .[Date] in the formula. Below is the article for your reference. If it is not your case, please share some data sample. You can upload it to OneDrive or Dropbox and post the link here.

 

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

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.