Forum Discussion

mmcanelly's avatar
mmcanelly
Helper II
2 years ago
Solved

Override page-level date filter for visual

I have a problem that seems fairly simple that I've spent half the day trying (unsuccessfully) to solve. I have a line chart on a report where I want to always show the past 5 years of history, regar...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi mmcanelly ,

    The test data sheet name is 'Table':

    You can use the following DAX to create a New Table:

    Last5YearsData = 
    CALCULATETABLE(
        'Table',
        FILTER(
            ALL('Table'[Year]),
            'Table'[Year] >= MAX('Table'[Year])-4)
    )
    

    The table you created 'Last5YearsData' will only contain data for the last 5 years.
    Then use the table you just created, 'Last5YearsData', to create a line chart. And the final output is shown in the following figure:

    When I apply the filter, nothing changes:

    When I applied slicer, it didn't change either:

    Note that when the year comes to the next, you only need to refresh it and you don't need to do anything else to update the line chart.

    Best Regards,

    Dino Tao

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