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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.