Forum Discussion
villa1980
Resolver II
1 year agofilter previous 2 years power query help
Hi all, I have a table that is currently looking at data from 2021 in column TRANSACTION_DATE. I would like to filter this in Power Query M to Transaction_Date is >= 2 years previous (which wi...
- 1 year ago
Managed to find the solution....
Table.SelectRows(#"Changed Type", each [TRANSACTION_DATE] >= DateTime.Date(Date.AddYears(DateTime.LocalNow(),-2)))
- 1 year ago
Hi villa1980 ,
In power query, please add a new custom column using this M code to get the year:
Date.Year([TRANSACTION_DATE])Now in APPLIED STEPS, right click in last step and inser step after with this M code:
= Table.SelectRows(#"Added Custom", each [Custom] >= Date.Year(DateTime.LocalNow()) - 2)This will dynamically adjust each year and include data for the last two years plus the current year.
Bibiano_Geraldo
Super User
1 year agoHi villa1980 ,
In power query, please add a new custom column using this M code to get the year:
Date.Year([TRANSACTION_DATE])
Now in APPLIED STEPS, right click in last step and inser step after with this M code:
= Table.SelectRows(#"Added Custom", each [Custom] >= Date.Year(DateTime.LocalNow()) - 2)
This will dynamically adjust each year and include data for the last two years plus the current year.