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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
rmeng
Helper II
Helper II

Display Last N Values when selected Slicer

I need a matrix that display the last 6 MonthYear when selected. The formula gives me the totals by column and not by row and I need them.

Can you help me with the formula below to give me too the totals by row.

Note: I´ve created a secondary calendar (Presentation Calendar) to help me with the formula.

rmeng_0-1618241172676.png

Focusedlast6Months=

    VAR CurrentDate =

        MAX ( 'DIM Calendar'[date] )

    VAR PreviousDate =

        EOMONTH ( CurrentDate-6 )

    VAR Result =

        IF (

            HASONEVALUE ( 'Presentation Calendar'[MONTH_YEAR] )

                && MAX ( 'Presentation Calendar'[Date] ) <= CurrentDate

                && MIN ( 'Presentation Calendar'[Date] ) > PreviousDate,

            CALCULATE (

                'OVERALL&INTERACTIONS'[% Focused Average],

                FILTER (

                    ALL ( 'DIM Calendar'[MONTH_YEAR] ),

                    'DIM Calendar'[MONTH_YEAR] = VALUES ( 'Presentation Calendar'[MONTH_YEAR] )

                )

            ),

            BLANK ()

        )

    RETURN

        Result

Thank you

2 REPLIES 2
amitchandak
Super User
Super User

@rmeng , refer my video, when select one date/period, how to disply more than one date/period

https://youtu.be/44fGGmg9fHI?list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for the video I´ve watched and created a formula, but still don´t work, April shouldn´t be there. If I select March 2021 the month year to be display should be  Mar2021, Feb2021,Jan2021, Dec2020, Nov2020, Oct2020.

rmeng_0-1618247227200.png

This is my formula but still don´t work:

Last 6 Months =
Var MaxDate = MAXX(ALLSELECTED('Presentation Calendar'),'Presentation Calendar'[DATE])
Var MinDate = DATE(YEAR(MaxDate),MONTH(MaxDate)-6,DAY(MaxDate))
Return
CALCULATE( [% Focused Average],FILTER('DIM CALENDAR', 'DIM CALENDAR'[DATE] <= MaxDate && 'DIM CALENDAR'[DATE] >= MinDate))

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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