Forum Discussion
Rolling year based on index
Hi All,
I am trying to create a rolling year (sum of retail of last 12 months) based on index (NOT on date, I don't have dates like in the example!) for each location seperate but haven't quite got what I want. Right now I am using 2 querries but the second one is giving an error.
First one calculates the starting month of the rolling year, so the max index (this month) - 12 months
Rolling Year Index = MAX('Retail'[Index])-12The second one should SUM the retail figures if the index of the row is larger than the outcome of the measure above.
Rolling Year = CALCULATE(sum('Retail'[Retail Value]);'Retail'[Index]>[Rolling Year Index])But I get a error that a true/false expression is used with calculate.2 Replies
- v-chuncz-msft
Community Support
MxJ ,
You may add FILTER Function to the formula.
https://www.sqlbi.com/articles/filter-arguments-in-calculate/
- MxJFrequent Visitor
Thanks for your response! Unfortunatly I am not getting it to work with filter..
Rolling Year Index = MAX('Retail'[Index])-12 Rolling Year retail= CALCULATE(sum('Retail'[Value]);FILTER(ALL('Retail'[Index]);'Retail'[Index]>[Rolling Year Index]))It just sums everything, also before the last 12 months. Am I doing something wrong?