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
powerbiexpert22
Impactful Individual
Impactful Individual

rolling 12 months average quick measure

i generated quick measure for "rolling 12 months average sales" however it is not matching with actual measure. please see below pbix file

 

https://drive.google.com/file/d/1zuTSZE_dw6qJ5CcNi4MdDOH-EdEsEIwO/view?usp=drive_link

 

without quick measure
rolling12maverage =
CALCULATE(
    SUM(SalesFact[amount]),
    DATESINPERIOD(DateDim[Date],max(DateDim[Date]),-12,MONTH)
)/12
 
quick measure
Sales rolling average =
IF(
    ISFILTERED('DateDim'[Date]),
    ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
    VAR __LAST_DATE = ENDOFMONTH('DateDim'[Date].[Date])
    VAR __DATE_PERIOD =
        DATESBETWEEN(
            'DateDim'[Date].[Date],
            STARTOFMONTH(DATEADD(__LAST_DATE, -12, MONTH)),
            ENDOFMONTH(DATEADD(__LAST_DATE, 1, MONTH))
        )
    RETURN
        AVERAGEX(
            CALCULATETABLE(
                SUMMARIZE(
                    VALUES('DateDim'),
                    'DateDim'[Date].[Year],
                    'DateDim'[Date].[QuarterNo],
                    'DateDim'[Date].[Quarter],
                    'DateDim'[Date].[MonthNo],
                    'DateDim'[Date].[Month]
                ),
                __DATE_PERIOD
            ),
            CALCULATE([Sales], ALL('DateDim'[Date].[Day]))
        )
)
 
powerbiexpert22_0-1722182079719.png

 

powerbiexpert22_0-1722183664565.png

 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @powerbiexpert22 -The main difference  in auto generated quick measure, it is using the DATESBETWEEN with DATEADD to get a 12-month range but adds an extra month (ENDOFMONTH(DATEADD(__LAST_DATE, 1, MONTH))) where as in custom measure Uses DATEPERIOD function to get a 12-month range directly. one more difference found at the aggregation that is calculated at quick measure,it uses averagex with a summarized table, which might include additional months and hence affect the result where as in custom measure it uses the sums the sales amount and then divides by 12 to get the average.

 

Once quick measure generated for rolling average, you can modify to use Dateperiod function and avoid adding the extra month.

Modified quick measure:

 

Sales rolling average =
IF(
ISFILTERED('DateDim'[Date]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __LAST_DATE = ENDOFMONTH(MAX('DateDim'[Date]))
VAR __DATE_PERIOD =
DATESINPERIOD(
'DateDim'[Date],
__LAST_DATE,
-12,
MONTH
)
RETURN
CALCULATE(
SUM(SalesFact[amount]),
__DATE_PERIOD
) / 12
)

 

Hope it gives you the same result like custom measure

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





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

Proud to be a Super User!





View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

I think you will get the correct answer with this measure

Measure = AVERAGEX(SUMMARIZE(CALCULATETABLE(DateDim,DATESBETWEEN(DateDim[Date],EDATE(MIN(DateDim[Date]),-11),MAX(DateDim[Date]))),DateDim[Year],DateDim[Month],"A",[Sales]),[A])

Hope this helps.

Ashish_Mathur_0-1722210708452.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
rajendraongole1
Super User
Super User

Hi @powerbiexpert22 -The main difference  in auto generated quick measure, it is using the DATESBETWEEN with DATEADD to get a 12-month range but adds an extra month (ENDOFMONTH(DATEADD(__LAST_DATE, 1, MONTH))) where as in custom measure Uses DATEPERIOD function to get a 12-month range directly. one more difference found at the aggregation that is calculated at quick measure,it uses averagex with a summarized table, which might include additional months and hence affect the result where as in custom measure it uses the sums the sales amount and then divides by 12 to get the average.

 

Once quick measure generated for rolling average, you can modify to use Dateperiod function and avoid adding the extra month.

Modified quick measure:

 

Sales rolling average =
IF(
ISFILTERED('DateDim'[Date]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __LAST_DATE = ENDOFMONTH(MAX('DateDim'[Date]))
VAR __DATE_PERIOD =
DATESINPERIOD(
'DateDim'[Date],
__LAST_DATE,
-12,
MONTH
)
RETURN
CALCULATE(
SUM(SalesFact[amount]),
__DATE_PERIOD
) / 12
)

 

Hope it gives you the same result like custom measure

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





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

Proud to be a Super User!





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.