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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MacedoLuis
New Member

MAT Based Previous Quarters

vl_salesyearquarterCategoty
113mi20211Kit Kat
114mi20212Nescau
100mi20213Chocolate
87mi20214Nescau
88mi20221Beve
115mi20222Iorgurt
77mi20223Nesquit
100mi20224Nescau
90mi20231Cookies


dim_calendar

yearquarterquarter_list
20211202101
20212202102
20213202103
20214202104
20221202201
20222202202
20223202203
20224202204
20231202301
20232202302
20233202303
20234202304


How can I calculate Moving Annual Sales for previous 4quarters, in way that 2023 Q1 = sum of values of the lasts 4 quarters, 
and 2022 Q4 = sum of values of the lasts 4 quarters, and so on? Any Help?

2 REPLIES 2
amitchandak
Super User
Super User

@MacedoLuis , Create a new Rank column in dim calendar (calling it date in my formula)

 

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

 

 

Then you can have measure like
This Qtr = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])))
Last Qtr = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])-1))

 

 


Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

 

Power BI Custom Period Till Date (PTD)- https://youtu.be/rQ3Z_LtxwQM

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  I tried it, and got blanks. And also tried like this, but i got blanks. Would you have another to calculate it?

fx_MovingAnnualTotal =
VAR fx_calendartable =
    SUMMARIZE(DimCalendario,
        DimCalendario[Data],
        DimCalendario[Quarter],
        DimCalendario[Trim_Ano],
        "@Qtr Rank",
        RANKX(ALL(DimCalendario), DimCalendario[Trim_Ano],,ASC,Dense)
    )
VAR fx_LastQtr =
    CALCULATE([Faturamento na Venda], FILTER(fx_calendartable, [@Qtr Rank] = MAXX(fx_calendartable, [@Qtr Rank])-1))
RETURN
fx_LastQtr

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.