Forum Discussion
How can I stop cumulative total?
- 4 years ago
Anonymous
Please refer to this solution Solved: Cumulative total - stopping after last date not wo... - Microsoft Power BI Community
Regards,
Ritesh
Anonymous best practice is to add a column in your date table that checks for the last available date with sales, something like
DateWithSales =
INT('Date'[Date] <= MAX ( Sales[Order Date] ))
Then add it as filter to the filter pane of the report and set it to 1.
You can also do it robust to not need to add it to the filter pane by adding it to all your measures.
Somthing like, create this measure:
ShowValueForDates :=
VAR LastDateWithData =
CALCULATE (
MAX ( 'Sales'[Order Date] ),
REMOVEFILTERS ()
)
VAR FirstDateVisible =
MIN ( 'Date'[Date] )
VAR Result =
FirstDateVisible <= LastDateWithData
RETURN
Result
And then add it to your measure:
Sales YTD :=
IF (
[ShowValueForDates],
CALCULATE (
[Sales Amount],
DATESYTD ( 'Date'[Date] )
)
)
Anyway, for full explanation just go to the source 🙂 sqlbi.com:
https://www.daxpatterns.com/standard-time-related-calculations/
In case it answered your question, please accept the solution to help other members find it. Appreciate Your Kudos.
Showcase Report – Contoso By SpartaBI
Visit SpartaBI website Visit SpartaBI Linkdin Visit SpartaBI Facebook
SpartaBI Logo