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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Sania-F
Resolver I
Resolver I

display data for last 2 alternative months when a month is selected in slicer

HI All,

 

I have a requirement- when I select  mar, then matrix should display data of jan, mar. 

If I select apr, then display data of feb, april

If I select aug in slicer, matrix should display data of jun, aug.

What I am getting by default is just selected month. I need last 2 alternative months data.

 

SaniaF_0-1677572727187.png

#date #slicer #matrix #dax #powerbi #month

3 REPLIES 3
johnt75
Super User
Super User

I think you can adapt the technique shown in https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/ for your use case.

Hi @johnt75  , I need last 2 alternative months data. If I select Mar, feb must be skipped and Jan data should be shown. Any leads on this kind of scenario?

I think you can adapt the calculation item from the article to be

Calc item =
VAR ReferenceDate =
    MAX ( 'Date'[Date] )
VAR DatesToUse =
    UNION (
        DATESBETWEEN (
            'Previous Date'[Date],
            EOMONTH ( ReferenceDate, - 1 ) + 1,
            EOMONTH ( ReferenceDate, 0 )
        ),
        DATESBETWEEN (
            'Previous Date'[Date],
            EOMONTH ( ReferenceDate, - 3 ) + 1,
            EOMONTH ( ReferenceDate, - 2 )
        )
    )
VAR Result =
    CALCULATE (
        SELECTEDMEASURE (),
        REMOVEFILTERS ( 'Date' ),
        KEEPFILTERS ( DatesToUse ),
        USERELATIONSHIP ( 'Previous Date'[Date], 'Date'[Date] )
    )
RETURN
    Result

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors