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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Atanas_Atanasov
Helper II
Helper II

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:

Atanas_Atanasov_0-1723719421588.png

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

Atanas_Atanasov_1-1723719503973.png

Can you please help me show the last selected month? 

Thank you in advance, 

Atanas

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

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.

 

Jihwan_Kim_1-1723721585724.png

 

 

Jihwan_Kim_0-1723721571661.png

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

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Atanas_Atanasov
Helper II
Helper II

@Jihwan_Kim - Thank you so much!!! It worked like a charm! Take care and stay safe!

Jihwan_Kim
Super User
Super User

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.

 

Jihwan_Kim_1-1723721585724.png

 

 

Jihwan_Kim_0-1723721571661.png

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

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.