- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to Show the last 3 years in report
Hi,
I am tring to get the last 3 years in my report. it look like i have in my report years 2020 , 2019, 2018, 2017,2016,2015
i wnat to show onaly 2020,2019,2018
also if the year change to 2021
it should update to
2021,2020,2019 and hide 2018, 2017,2016,2015
thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting approach! 🙂
The built in date filters in Power Query behave the same regardless of current date, so when you filter for in the previous 1 years, it will give you all of 2019 right now. So to get 2018, 2019 and 2020 we can do an OR filter to get in the previous 2 years or in this year.
The below code will work assuming you replace
#"Changed Type1" with the name of your last step
[OrderDate] with the name of the date column:
= Table.SelectRows(#"Changed Type1", each Date.IsInPreviousNYears([OrderDate], 7) or Date.IsInCurrentYear([OrderDate]))
Otherwise just click the arrow filter on the date column and choose 'in the previous' and add the OR condition to also be in this year.
Please @mention me in your reply if you want a response.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Anonymous , if the year is coming from date. Use relative date slice
https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Anonymous ,
You need to filter data in Power Query.
As @AllisonKennedy mentioned, you can use built in functions to calculate last N months, years, days.
But if you want to make sure it calculates years, where last 3 years are 2018, 2019, 2020 no matter which current month it is, here is approach:
1) create new column for year based on data in table: Date.Year([Date])
2) create new column for current year: Date.Year(DateTime.Date(DateTime.LocalNow()))
3) create new column to calculate difference between current year and year in data: [Current Year]-[Year]
4) filter this colum to show only number 0,1,2 (it will filter only last 3 years)
Cheers,
Nemanja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting approach! 🙂
The built in date filters in Power Query behave the same regardless of current date, so when you filter for in the previous 1 years, it will give you all of 2019 right now. So to get 2018, 2019 and 2020 we can do an OR filter to get in the previous 2 years or in this year.
The below code will work assuming you replace
#"Changed Type1" with the name of your last step
[OrderDate] with the name of the date column:
= Table.SelectRows(#"Changed Type1", each Date.IsInPreviousNYears([OrderDate], 7) or Date.IsInCurrentYear([OrderDate]))
Otherwise just click the arrow filter on the date column and choose 'in the previous' and add the OR condition to also be in this year.
Please @mention me in your reply if you want a response.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have similar problem but i'm not able to decide how to put your solution into it.
I just want that when i click at the slicer of year (same as the one in the question) I should see the graphs as it is but along with that in the other visual i want to see only the past 3 years of sales/profit in number.
Can anyone please guide me. I did for the current year and last year by using the SAMEASLASTYEAR formula, visualised on the card. However, i tried alot of things but failed to do for last 2 years or mainly N-1, N-2 and N-3 year
Thank you so much in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please @mention me in your reply if you want a response.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources
Power BI Monthly Update - April 2025
Check out the April 2025 Power BI update to learn about new features.
NEW! Community Notebooks Gallery
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

Subject | Author | Posted | |
---|---|---|---|
03-25-2025 10:41 AM | |||
02-26-2024 12:45 PM | |||
03-19-2025 08:26 AM | |||
12-12-2024 04:32 AM | |||
11-27-2020 02:25 PM |
User | Count |
---|---|
16 | |
10 | |
8 | |
8 | |
7 |