Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I have a requirement to calculate the sum of a 12-month sales rolling average measure for a given material.
Final Result would look like this:
Date Slicer: 1/1/2022 – 12/31/2023
Material # | Sum of Sales Moving Average for each month within the scope of the date slicer. |
ABC | x |
CDE | x |
EFG | x |
HIJ | x |
KLM | x |
I’m able to calculate the 12-month sales rolling average value appropriately on other matrix/line charts with an appropriate Month-Year axis, but I’m having a hard time summing up the 12-month sales rolling average values in the matrix above.
The matrix above would need to interact with a date slicer and various other slicers related to material #.
So pretty much:
Any tips/suggestions are greatly appreciated. Thanks so much for your help!
Solved! Go to Solution.
Hi,
I am not sure if I understand your question correctly, but I tried to create a sample pbix file like below.
please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your datamodel.
Sales total: =
SUM( Sales[Sales] )
monthly rolling average: =
AVERAGEX (
VALUES ( 'Calendar'[Year-Month sort] ),
CALCULATE ( SUM ( Sales[Sales] ) )
)
_12months rolling average: =
VAR _selectedmaxdateslicer =
MAX ( 'Calendar'[Date] )
VAR _t =
SUMMARIZE (
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Date] <= EOMONTH ( _selectedmaxdateslicer, 0 )
&& 'Calendar'[Date]
>= EOMONTH ( _selectedmaxdateslicer, -12 ) + 1
),
'Calendar'[Year-Month sort]
)
RETURN
AVERAGEX ( _t, CALCULATE ( SUM ( Sales[Sales] ) ) )
sum of 12months rolling avg: =
SUMX ( VALUES ( 'Calendar'[Year-Month sort] ), [_12months rolling average:] )
Awesome! Yes, this is the proof of concept I was looking for. Thank you so much!
Hi,
I am not sure if I understand your question correctly, but I tried to create a sample pbix file like below.
please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your datamodel.
Sales total: =
SUM( Sales[Sales] )
monthly rolling average: =
AVERAGEX (
VALUES ( 'Calendar'[Year-Month sort] ),
CALCULATE ( SUM ( Sales[Sales] ) )
)
_12months rolling average: =
VAR _selectedmaxdateslicer =
MAX ( 'Calendar'[Date] )
VAR _t =
SUMMARIZE (
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Date] <= EOMONTH ( _selectedmaxdateslicer, 0 )
&& 'Calendar'[Date]
>= EOMONTH ( _selectedmaxdateslicer, -12 ) + 1
),
'Calendar'[Year-Month sort]
)
RETURN
AVERAGEX ( _t, CALCULATE ( SUM ( Sales[Sales] ) ) )
sum of 12months rolling avg: =
SUMX ( VALUES ( 'Calendar'[Year-Month sort] ), [_12months rolling average:] )
Hi,
Quick follow up question. For the "_12 months rolling average" calculation, if I wanted to include the entire dataset in the scope of the 12 month rolling average calculation, what would be the best adjustment to the measure?
Ex. With the date slicer set to 1/1/2022 -1/31/2022, the current "_12 months rolling average" measure would be equal to the total sales in january 2022, but I would want the _12 months rolling average" calculation to consider the sales for 2/1/2021 - 1/31/2022.
Thanks in advance!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |