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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.