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
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

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
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.

Top Solution Authors