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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Kudoed Authors