Forum Discussion
murphm6
Helper II
3 years agoHelp calculating 12 month trailing sum in table
Hi all, i want to calculate a twelve month trailing sum of the volume column for each individual prod pkg code - how can i do this? I've tried doing CALCULATE(SUM('Table' [Vol(CUR]), DATESINPERIO...
Greg_Deckler
Community Champion
3 years agomurphm6 It's almost the exact same formula, you just have to drop the MAX aggregation:
Better Rolling Sum =
VAR __EndDate = 'Table'[Date]
VAR __3MonthsAgo = EOMONTH(__EndDate, -12)
VAR __StartDate = DATE(YEAR(__3MonthsAgo), MONTH(__3MonthsAgo), 1)
VAR __Table =
SUMMARIZE(
FILTER(ALL('Table'),[Date]>=__StartDate && [Date]<=__EndDate),
'Table'[Month],
"__Value",SUM('Table'[Value])
)
RETURN
SUMX(__Table,[__Value])
murphm6
Helper II
3 years agoSo i think this is on the right track but it's not accounting for each prod-pkg code, rather it's just summing the entire thing. What can I add to ensure it also considers the prod-pkg-code column?