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! Request now

Reply
PBI_newuser
Post Prodigy
Post Prodigy

How to display only latest month data when year is selected

Hi, I want to display only the latest month data when the year is selected. 

For example, when Year = 2021 is selected, just show Product C and when Year = 2022 is selected, just show Product D.

 

ProductMonth
A2021-10
B2022-02
C2021-11
D2022-03
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @PBI_newuser ,

Please refer to my  step to see if it helps you. 

Create a colun first.

 

year_ = YEAR('Table'[Month])

 

Then create a measure.

 

Measure = 
VAR answer =
    CALCULATE (
        MAX ( 'Table'[Product] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[year_] = SELECTEDVALUE ( 'Table'[year_] )
                && 'Table'[Month] >= SELECTEDVALUE ( 'Table'[Month] )
        )
    )
RETURN
    IF ( answer = MAX ( 'Table'[Product] ),1, 0 )

 

Then filter the data.

11.PNG

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @PBI_newuser ,

Please refer to my  step to see if it helps you. 

Create a colun first.

 

year_ = YEAR('Table'[Month])

 

Then create a measure.

 

Measure = 
VAR answer =
    CALCULATE (
        MAX ( 'Table'[Product] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[year_] = SELECTEDVALUE ( 'Table'[year_] )
                && 'Table'[Month] >= SELECTEDVALUE ( 'Table'[Month] )
        )
    )
RETURN
    IF ( answer = MAX ( 'Table'[Product] ),1, 0 )

 

Then filter the data.

11.PNG

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi Polly,

I am trying to do something similar but I only need to display the latest month value in a slicer or a card when the year is chosen and there is existing data. (The data itself shows up in matrix tables in a separate visual)

 

 

In other words:

if the year filter is 2022 then "Month" on the card would reflect the latest month that contained data. For what I'm doing as of today, we have data through July so the card or slicer would display "July".

 

For prior years (2021, 2020, etc.), the latest month would be December as there would be a full year's worth of data so the card or slicer would display "December".

 

Could you help?

Thank you!

amitchandak
Super User
Super User

@PBI_newuser , Assuming month year is in the given format only

Use a measure like this in visual or visual level filter

 

calculate(lastnonblankvalue(Table[Month], Countrows(Table)) )

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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