Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MxJ
Frequent Visitor

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])-12

The 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.
 
I have added some of the data I use. So location A should SUM index 3-14, B also index 3-14 and C index 5-16
 
Any tips? 
 
Thanks in advance! 

set.PNG
2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@MxJ ,

 

You may add FILTER Function to the formula.

https://www.sqlbi.com/articles/filter-arguments-in-calculate/

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-chuncz-msft 

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?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.