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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
AshDil
Helper V
Helper V

Rolling 12 month Sum for prior 2 years

Hi, 
I have 2 slicers one for year and other for month. If I have selected year as 2021 and month as January, then need to show rolling 12 month sum for periods,

Feb 2020 - Jan 2021
Feb 2019 - Jan 2020
Please help me to do.

Thanks,
AshDil.

 

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

Try these measures

Total sales = sum(Data[sales])

Sales in last 12 months = calculate([total sales],datesbetween(calendar[date],edate(min(calendar[date])-11),max(calendar[date])))

Sales before = calculate([Sales in last 12 months],sameperiodlastyear(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Hi @AshDil .

In that case create 2 separate measures with little tweak in the same formula.

 

For last 12 months;

Rolling Sum for last year= CALCULATE(
[Total Sales],
DATESINPERIOD(Table[Date],
MAX(Table[Date]),
-1,
YEAR))

 

Rolling Sum before last 12 months=CALCULATE[Rolling Sum for last year],
SAMEPERIODLASTYEAR(Table[date]).

 

Please let me know if that works for you.

 

Regards,

Sanket Bhagwat

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Try these measures

Total sales = sum(Data[sales])

Sales in last 12 months = calculate([total sales],datesbetween(calendar[date],edate(min(calendar[date])-11),max(calendar[date])))

Sales before = calculate([Sales in last 12 months],sameperiodlastyear(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
SanketBhagwat
Solution Sage
Solution Sage

Hi @AshDil .

1)Create a measure for Total Sales as;
Total Sales=SUM(Sales).

 

2)Create a measure for rolling sum as ;
Rolling Sum for last 2 years= CALCULATE(
[Total Sales],
DATESINPERIOD(Table[Date],
MAX(Table[Date]),
-2,
YEAR)).

 

Pleast let me know if it works.

 

Regards,

Sanket Bhagwat.

Hi @SanketBhagwat ,
If I have used above calculation I will get rolling sum for last 24 months i.e, FEB 2019 - JAN 2021, not for 12 month sum seperately.

I want to show 2 seperate 12 month sum for periods

Feb 2020 - Jan 2021
Feb 2019 - Jan 2020
 
Thanks,
AshDil.

Hi @AshDil .

In that case create 2 separate measures with little tweak in the same formula.

 

For last 12 months;

Rolling Sum for last year= CALCULATE(
[Total Sales],
DATESINPERIOD(Table[Date],
MAX(Table[Date]),
-1,
YEAR))

 

Rolling Sum before last 12 months=CALCULATE[Rolling Sum for last year],
SAMEPERIODLASTYEAR(Table[date]).

 

Please let me know if that works for you.

 

Regards,

Sanket Bhagwat

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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