Forum Discussion
Problems with Running Totals
Daniel29195
I'm not sure what I'm missing. I was able to follow your suggestion all the way until the adding of two columns for Year and Month. But I was not sure how it plays the role inside of measure since the code for the measure is the same as before.
Anonymous sorry my bad .
i copied yours to modify it, but it seems i didnt work .
anw
try using this one :
Sales $ RT =
VAR MaxOrd = CALCULATE(MAX('DateDim'[yearmonthfull]))
VAR year = year(MaxOrd)
VAR Results =
CALCULATE (
[Sales $],
'DateDimX'[yearmonthfull] <= MaxOrd,
year('DateDimX'[yearmonthfulll]= year ,
REMOVEFILTERS(DateDim)
)
RETURN
Results
tell me if it works for you .
- Anonymous2 years agoNot applicable
Daniel29195
I used your suggestion and it is still not doing running total instead just showing the total for each month. Addinitionally, your solution starts at the beginning of the year instead of going back 12 months.Here is modified code that I used based on your feedback.
Sales $ RT 1 VAR MaxDate = CALCULATE(MAX('DateDim'[FirstDayOfMonth])) VAR CurrentYear = YEAR(MaxDate) VAR Results = CALCULATE ( [Sales $], 'DateDim'[FirstDayOfMonth] <= MaxDate, YEAR('DateDim'[FirstDayOfMonth]) = CurrentYear, REMOVEFILTERS(DateDim) ) RETURN ResultsI also tried a different solution of using DATESINPERIOD, it still produces only the 12 months worth of data but does not make it into running total.
Sales $ RT 2 = VAR SelectedMonth = SELECTEDVALUE('DateDim'[FirstDayOfMonth]) VAR RollingPeriod = DATESINPERIOD('DateDim'[FirstDayOfMonth], SelectedMonth, -12, MONTH) VAR Results = CALCULATE ( [Sales $], RollingPeriod, REMOVEFILTERS(DateDim) ) RETURN Results