Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello Forum helpers
Help needed in creating a Rolling 12 Month Sales ignoring Year and Week slicer. I've created a rolling 12 month for sales, but problem lies when using the slicer (Lets say I enter 2020), the Rolling sale calculation throwing wrong figure. Measures included in my PBIX file with Date table [Cumulative Rolling Sales, Month Running Index].
What I'm aiming for the 12 month Rolling measure which ignore Year and Week. Added a PBIX File to download with my example below.
Measure created based on solution provided by [TomMartens] https://community.powerbi.com/t5/Desktop/Rolling-Avg-calculation-should-ignore-date-slicer/td-p/6891....
Appreciate your help in advance.
Many Thanks
Solved! Go to Solution.
To achieve this, you'll want to use the ALL function in DAX to remove any filters applied by the slicers. The ALL function essentially clears any filters that might be applied to the specified table or column.
Given that you already have a measure for Cumulative Rolling Sales and a Month Running Index, let's try to modify your Rolling 12 Month Sales measure to ignore the slicers:
Rolling 12 Month Sales =
CALCULATE(
[Cumulative Rolling Sales],
FILTER(
ALL('DateTable'),
'DateTable'[Month Running Index] <= MAX('DateTable'[Month Running Index]) &&
'DateTable'[Month Running Index] > MAX('DateTable'[Month Running Index]) - 12
)
)
Here's a breakdown of what's happening:
CALCULATE changes the context in which the data is evaluated.
FILTER is used to create a new table that contains only the rows you're interested in.
ALL('DateTable') removes any filters on the DateTable, ensuring that the slicers don't affect the calculation.
The conditions inside the FILTER function ensure that only the last 12 months, including the current month, are considered.
By using this measure, even if you select a specific year or week using the slicer, the Rolling 12 Month Sales measure should give you the total sales for the last 12 months, ignoring the slicer selection.
To achieve this, you'll want to use the ALL function in DAX to remove any filters applied by the slicers. The ALL function essentially clears any filters that might be applied to the specified table or column.
Given that you already have a measure for Cumulative Rolling Sales and a Month Running Index, let's try to modify your Rolling 12 Month Sales measure to ignore the slicers:
Rolling 12 Month Sales =
CALCULATE(
[Cumulative Rolling Sales],
FILTER(
ALL('DateTable'),
'DateTable'[Month Running Index] <= MAX('DateTable'[Month Running Index]) &&
'DateTable'[Month Running Index] > MAX('DateTable'[Month Running Index]) - 12
)
)
Here's a breakdown of what's happening:
CALCULATE changes the context in which the data is evaluated.
FILTER is used to create a new table that contains only the rows you're interested in.
ALL('DateTable') removes any filters on the DateTable, ensuring that the slicers don't affect the calculation.
The conditions inside the FILTER function ensure that only the last 12 months, including the current month, are considered.
By using this measure, even if you select a specific year or week using the slicer, the Rolling 12 Month Sales measure should give you the total sales for the last 12 months, ignoring the slicer selection.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
23 | |
21 | |
20 | |
14 | |
12 |
User | Count |
---|---|
43 | |
31 | |
25 | |
22 | |
22 |