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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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