Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hello All
I need to modify this M-Code so that it is only keeping data for the last 5 years beginning on or after 1 Oct of that 5th year. As an example, right now in 2021 I would want data all the way back to 1 Oct 16. However, I need this to be dynamic so that it always just calculates 5 years back and to 1 Oct of the 5th year----no matter what year we are currently in. Another example: In 2023, I'll want it to look at data >= 1 Oct of 2018.
When using Power Query it wants a "year" for the 1 Oct date. How do I modify this so that it does not require a year on the 1 Oct date?
= Table.SelectRows(#"Changed Type", each Date.IsInPreviousNYears([Date Arrived Personnel Office], 5) and [Date Arrived Personnel Office] >= #date(2016, 10, 1))
Solved! Go to Solution.
Please try using this filter step instead
= Table.SelectRows(#"Changed Type", each [Date Arrived Personnel Office] >= #date(Date.Year(DateTime.LocalNow())-5, 10, 1))
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Please try using this filter step instead
= Table.SelectRows(#"Changed Type", each [Date Arrived Personnel Office] >= #date(Date.Year(DateTime.LocalNow())-5, 10, 1))
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks Pat. It worked perfect!
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 4 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 7 | |
| 6 | |
| 5 |