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
BItoken
Helper III
Helper III

Urgent - Trailing 4 quarters Sum

Hi Everyone,

 

I have last 12 Qtrs in my Power BI report and i have to add a column to show Trailing 4 quarters sum running until the current qtr

For example i need

Sum of FY19-Q1,Q2,Q3,Q4 at FY-19Q4

Sum of FY19-Q2,Q3,Q4,FY20-Q1 at FY20-Q1

Sum of FY19 Q3,Q4,FY20-Q1,Q2 at FY20-Q2

and so on

 

Trailing 12 Months.png

 

Any Suggestions... Tried Rank on quarters but does not help

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.  Let me know if you are OK with this.  If you want the first 3 rows to definitely show a blank, then post back and i will modify my formula.

Hope this helps.

Untitled.png


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

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Is your input table, the first 2 columns?  If yes, then share the data in a form that can be pasted in an MS Excel file.  Which months fall in Q1?


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

Yes first 2 columns are coming from my Data tables.

Apr to June is Q1

So ex: Apr 1 2020 to June 30 2020 is FY 21 Q1

 

FQSalesTrailing 4 Qtrs
FY19-Q140 
FY19-Q250 
FY19-Q370 
FY19-Q460220
FY20-Q140220
FY20-Q280250
FY20-Q3100280
FY20-Q4200420
FY21-Q1  
FY21-Q2  
FY21-Q3  
FY21-Q4  

Hi,

You may download my PBI file from here.  Let me know if you are OK with this.  If you want the first 3 rows to definitely show a blank, then post back and i will modify my formula.

Hope this helps.

Untitled.png


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

create an ascending rank on Qtr (In case you do not have Date)

Make sure Your Qtr in in Different table

Qtr Rank = RANKX(all('Date'),'Date'[Qtr Start date],,ASC,Dense)

Or

Qtr Rank = RANKX(all('Date'),'Date'[Qtr name],,ASC,Dense)

Last 4week Qtr = CALCULATE(SUM(Sales[Net Sales]),FILTER(all('Date'),'Date'[Week Qtr ]>=min('Date'[Week Qtr ])-4 && 'Date'[Week Qtr ]<=max('Date'[Week Qtr ])))

This Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Qtr ]=max('Date'[Week Qtr ])))
Last Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Qtr ]=max('Date'[Week Qtr ])-1))


 

In case you have Date , prefer a date table and rolling

Rolling 4 Qtr  = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD(Table[Date],ENDOFMONTH(Sales[Sales Date]),-4,QUARTER))

 

https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...

 

 

Hi,

 

I already created a Rank on the Qtr table which is a separate table

Also i created  a measure on this rank 

trailing 4 Qtrs =  CALCULATE(SUM([Sales]),
FILTER(Qtr, Qtr[Rank] >= MIN(Qtr[Rank])-4 && Qtr[Rank] <= MAX(Qtr[Rank])))
It just gets the data for sales per Qtr (Nothing happens)

 

 Rank.png

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.