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
dragon_prince
Frequent Visitor

Rolling 4 quarter sum for each selected quarter

Hi,
I have data at snapshot date level.One snapshot date for in each quarter first day. I want to get the rolling 4 quarter for each quarter selected. Refer image below. r4q is the expected output. 
March is the Fiscal Quarter Start. 

Granularity of data - Snapshot Date x subscription id

 

input 
snapshot_datearr
01 March 202016
01 May 202011
01 May 202017
01 November 202019
01 February 202111
01 May 202116
01 August 202117
01 November 202115
01 February 202219
01 May 202212
01 August 202210
01 November 202215
Output 
snapshot_dater4q_arr
01 November 202159
01 February 202267
01 May 202263
01 August 202256
01 November 202256
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @dragon_prince 

If you don't have a calendar table, you can also create a measure like this:

r4q_arr =
VAR _date =
MIN(TableName[snapshot_date])
RETURN
CALCULATE(
   SUM(TableName[arr]),
   TableName[snapshot_date]<=_date,
   TableName[snapshot_date]>=EDATE(_date, -12)
)
 
Plot a table visual with the date column and the measure.

View solution in original post

7 REPLIES 7
dragon_prince
Frequent Visitor

FreemanZ
Super User
Super User

hi @dragon_prince 

If you don't have a calendar table, you can also create a measure like this:

r4q_arr =
VAR _date =
MIN(TableName[snapshot_date])
RETURN
CALCULATE(
   SUM(TableName[arr]),
   TableName[snapshot_date]<=_date,
   TableName[snapshot_date]>=EDATE(_date, -12)
)
 
Plot a table visual with the date column and the measure.

Hi @FreemanZ,

There is an issue here, 
If i am filtering for specific quarters, the correct value is not populating. Say if i select 5 quarters, only the 4 and 5th quarter values will have the correct r4q values populating. The rest will only take the available quarter. 

The expected filter is even if select  4 dates, for the first date , it should show the R4Q arr even though the previous dates may not be selected. 

 

Input  
snapshot_dateSum of arrr4q
01 August 20191142
01 November 20191961
01 February 2020647
01 May 20201046
01 August 20201348
01 November 20201544
01 February 2021745
01 May 20211550
01 August 20212057
01 November 2021951
01 February 20221660
01 May 2022752
01 August 20222052
01 November 20221356
   
Output  
snapshot_dateSum of arrr4q
01 February 20221660
01 May 2022752
01 August 20222052
01 November 20221356

hi @dragon_prince 

how do you perform the "filtering for specific quarters"?

I have added a filter at the top, where i select 4 snapshot quarters. 

pratyashasamal
Super User
Super User

Hi @dragon_prince ,
Try this calculation:-
CALCULATE([Sales QTD],DATESBETWEEN('Calendar'[Date],EDATE(MIN('Calendar'[Date]),-9),MAX('Calendar'[Date])))
Thanks,
Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





@ Tried this, 
It is returning the same value in arr.

dragon_prince_0-1674212487497.png

Formula for Measure used 

r4q2 = CALCULATE(sum('Table'[arr]),
          DATESBETWEEN('Calendar (2)'[Date]
                       ,EDATE(MIN('Calendar (2)'[Date]),-9)
                       ,MAX('Calendar (2)'[Date])))

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.