Forum Discussion
cummulative sum not working
- 6 months ago
That's actually simpler DAX code, you can use the DATESYTD function
Cumm Sum USD = CALCULATE ( SUM ( 'Actuals'[Actual USD] ), DATESYTD ( 'DimDate'[Date] ) )
There's a couple of points here. Its best practice to use fields from your date table in visualisations and measures, rather than using the date field from your fact table.
Also, you are filtering all the dates before today, rather than filtering for all the dates before the last date visible in the context.
Try
Cumm Sum USD =
VAR MaxDate =
MAX ( 'DimDate'[Date] )
VAR Result =
CALCULATE ( SUM ( 'Actuals'[Actual USD] ), 'DimDate'[Date] <= MaxDate )
RETURN
Result
johnt75
Thank you, it partially works ( sums per month are correct - cummulative).
I would like to have a possibility, that the sum will be only fro selected Year/Month in Slicer.
I am having sales for 3 years : 2024-2026,
then if I select 2025 in Selector, then graph should adjust to only 2025 months, but values are still counted from the beggining ( since 2024).
Could you please help me on that as well?
Very much approciated.
- johnt756 months agoSuper User
That's actually simpler DAX code, you can use the DATESYTD function
Cumm Sum USD = CALCULATE ( SUM ( 'Actuals'[Actual USD] ), DATESYTD ( 'DimDate'[Date] ) )