Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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!!
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!
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.
Proud to be a Super User!
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 |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |