Forum Discussion

Atanas_Atanasov's avatar
2 years ago
Solved

Showing Last Selected Month

Dear All, 

 I'd like to show the name of the last selected Month And Year when having multiple selections in my slicer.

For example if Janunary, February, March, April, May and June are selected I'd like to show June 2020 on all rows.

I managed to do it with the date column as shown here:

But when I use the Month and Year column in my code I got different result. Instead of having JUN 2020 I got MAY 2020

Can you please help me show the last selected month? 

Thank you in advance, 

Atanas

  • Hi,

    I think, the reason is because of the sort order column is missed in the measure.

    Please try something like below.

    I tried to create a sample pbix file like below.

    please check the below picture and the attached pbix file.

     

     

     

    Selected Period: =
    VAR _maxdate =
        CALCULATE (
            LASTNONBLANK ( dim_calendar[month year sort], [Total orders:] ),
            ALLSELECTED ( dim_calendar )
        )
    RETURN
        SELECTCOLUMNS (
            FILTER ( ALL ( dim_calendar ), dim_calendar[month year sort] = _maxdate ),
            dim_calendar[month year]
        )
    

     

     

2 Replies

  • Hi,

    I think, the reason is because of the sort order column is missed in the measure.

    Please try something like below.

    I tried to create a sample pbix file like below.

    please check the below picture and the attached pbix file.

     

     

     

    Selected Period: =
    VAR _maxdate =
        CALCULATE (
            LASTNONBLANK ( dim_calendar[month year sort], [Total orders:] ),
            ALLSELECTED ( dim_calendar )
        )
    RETURN
        SELECTCOLUMNS (
            FILTER ( ALL ( dim_calendar ), dim_calendar[month year sort] = _maxdate ),
            dim_calendar[month year]
        )