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
Happy2023_05
Helper I
Helper I

How to show last 2 years data using measure?

Hi All,

I have date table with 3 yrs of data.When I want to bring the date to slicer I should see only 2 yrs of data. For eg slicer should show 2022 and 2021. Next year it should be 2023 and 2022. It should not be hard-coded in filters.

Automatically only 2 yrs value should be shown in slicer

Can we bring this in measure?

Any help is much appreciated

1 ACCEPTED SOLUTION

Hi,

Thank you for your feedback.

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

One of ways is to apply calculated column to report level filter pane.

 

Jihwan_Kim_0-1665571982341.png

 

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.


Go to My LinkedIn Page


View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

one of ways to achieve this is to create a measure something like below, and put it into Visual Filter pane and set it up like below.

Please also check the attached pbix file.

 

Jihwan_Kim_0-1665568516529.png

 

Last two years measure: = 
VAR _currentyear =
    YEAR ( TODAY () )
VAR _previousyear = _currentyear - 1
RETURN
    IF (
        SELECTEDVALUE ( 'Year'[Year] ) = _currentyear
            || SELECTEDVALUE ( 'Year'[Year] ) = _previousyear,
        1,
        0
    )

 

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.


Go to My LinkedIn Page


Thank you so much.But when I try to apply this measure for all pages I could not bring the measure to filter on all pages. Is there any other way to do it?

Hi,

Thank you for your feedback.

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

One of ways is to apply calculated column to report level filter pane.

 

Jihwan_Kim_0-1665571982341.png

 

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.


Go to My LinkedIn Page


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