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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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