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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Saskwyt
Frequent Visitor

12 Month Rolling Cumulative Sales

Hi,

 

I wondered if someone can help me please? After searching the forum I can't quite find an appropriate answer.

 

What i'm trying to achieve is a rolling 12 months cumulative sales. So that when I change the "To Date" on the date slicer it automatically looks back 12 months and calculates the cumulative sales.

 

Data in the model:

I have a list of orders with dates and values from 2020 to 2023 - This comes from a spreadsheet and is called Excel_Data in the model. I also have a date table which is linked to the Excel_Data table.

I also have a DAX measure called YTD_SALES_CY:

YTD_SALES_CY = 
CALCULATE(Sum(Excel_Data[CompanyNotesCost]),
    FILTER(
        ALL(Date_Table),
        And(Date_Table[Date]<= Max(Date_Table[Date]),
            Date_Table[Date]>eomonth(CALCULATE(MAX(Date_Table[Date]), ALLSELECTED(Date_Table)),-14)
            )
          )
        )

 

The DAX measure I have above seems to be pretty close. The issue seems to be with the "From date" as this doesn't change when the "To Date" changes.

In simple terms - When I enter 31/12/2022 as my "To Date" in the slicer, I get 12 months worth of data. When I select 31/01/2023 as my "To Date" I get 13 months of data, 28/02/2023 I get 14 months of data, 30/06/2022 I get 6 months of data. I want to always have 12 months of data looking back from my "To Date"

 

Please see below a link to my file and many thanks in advance!!

 

https://t4designlimited-my.sharepoint.com/:u:/g/personal/markshort_t4design_com/EVExCE3KLOlAmCKBARpz...

2 REPLIES 2
Saskwyt
Frequent Visitor

Hi @ValtteriN thank you so much for your response. I'm so sorry but i don't fully understand your answer.

 

I've added a new measure to the file based on what I think is needed but this doesn't give me the right answer.

 

Could you explain in a bit more detail and perhaps provide a specific solution in the file?

https://t4designlimited-my.sharepoint.com/:u:/g/personal/markshort_t4design_com/EVExCE3KLOlAmCKBARpz...

 

Thanks again!

ValtteriN
Super User
Super User

Hi,

For rolling 12M I usually use this kind of structure:

CALCULATE ( selectedmeasure(), DATESBETWEEN ( 'Calendar'[Date], DATEADD ( LASTDATE ( DATEADD ( 'Calendar'[Date], -12, MONTH ) ), +1, DAY ), LASTDATE ( 'Calendar'[Date] ) )  )


Just place your calculation logic in the "selectedmeasure()" slot.





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

Proud to be a Super User!




Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors