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
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
v-rongtiep-msft
Community Support
Community Support

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
v-rongtiep-msft
Community Support
Community Support

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

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.