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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mmcanelly
Helper I
Helper I

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, regardless of what date filters are applied to the report. Here's an example of what the chart looks like:

mmcanelly_0-1699481696462.png

If I filter the report by a single year with the Year filter I have on the page, it will only show 1 point on this line chart. The basic measure I've set up to try to solve this is as follows:

CALCULATE (
    [Other Measure],
    Dates[YearsAgo] < 5
)

This on its own doesn't ignore the date filter that's set on the report, so I've tried different DAX solutions by using ALL(), REMOVEFILTERS(), and ALLEXCEPT() in different ways within the CALCULATE() expression. The results I end up with in all these cases are either (1) The measure calculates a single value for the entire dataset because it's ignoring the year, so I end up with a straight line on the line chart, or (2) The Year filter on the page will still filter down the chart to a single point.

 

It looks like there's a common solution using a slicer and the Edit Interactions function, but I'm not currently using slicers on this report and I would rather not, since it would be a little confusing for the user with some filters appearing in slicers on the report and some appearing in the filter pane.

 

This seems like a super simple problem, but I can't figure out what I'm doing wrong here. Any advice to keep my chart consistently showing 5 years regardless of the Year filter set on the report?

1 ACCEPTED SOLUTION
v-junyant-msft
Community Support
Community Support

Hi @mmcanelly ,

The test data sheet name is 'Table':

vjunyantmsft_0-1699601341424.png

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:

vjunyantmsft_1-1699601432357.png

When I apply the filter, nothing changes:

vjunyantmsft_2-1699601460909.png

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

vjunyantmsft_3-1699601493989.png

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.

View solution in original post

1 REPLY 1
v-junyant-msft
Community Support
Community Support

Hi @mmcanelly ,

The test data sheet name is 'Table':

vjunyantmsft_0-1699601341424.png

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:

vjunyantmsft_1-1699601432357.png

When I apply the filter, nothing changes:

vjunyantmsft_2-1699601460909.png

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

vjunyantmsft_3-1699601493989.png

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.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.