cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills 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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors