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
siva54
Helper I
Helper I

Last N quarters from selected quarter and year

Hi Team,

 

I have requirement that when i'm selected quarter, bar graph need to show last 5 quarters from selected quarter.

I have sales table and i need to check how many sales are happend in last 5 quarters.

 

For example,

 

I have year Slicer and Quarter Slicer, i selected 2023 qtr 1 then i need to show
              qtr1-23,
              qtr4-22,
              qtr3-22,
              qtr2-22,
              qtr1-22

Regards,
Siva

5 REPLIES 5
siva54
Helper I
Helper I

@johnt75 ,

 

I have used this dax 

Last4Qtrs =

VAR NumOfqtr =-4
VAR ReferenceDate = MAX ( 'Date'[Date] )
VAR PreviousDates =
    DATESINPERIOD (
        'Previous Date'[Date],
        ReferenceDate,
        NumOfqtr,
        QUARTER
    )
VAR Result =
    CALCULATE (AVERAGE('WB Tbl_R2R_SLA_Trend'[Actual_Value]),
        REMOVEFILTERS ( 'Date' ),
        KEEPFILTERS ( PreviousDates ),
        USERELATIONSHIP ( 'Previous Date'[Date], 'Date'[Date] )
    )
RETURN Result
 
I'm getting an extra quarter like this siva54_0-1686046653549.png

 

Check that the date column in your fact table, which is linked to the date table, is of type date and not datetime. You'll need to check in both Power Query and in Power BI desktop.

siva54
Helper I
Helper I

Hi Johnt75,

 

It is working for monthly scenario, when it comes to Quarter it is not working. Could you please help me.

The principle should be the same, you would need to modify the measure or calculation item to take into account quarters rather than months.

johnt75
Super User
Super User

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.