Forum Discussion
filter previous 2 years power query help
- 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.
Hi Bibiano_Geraldo ,
Just found this query because I need to do the same and saw the solution that you have proposed. I'd like to know what is the difference between that solution and the following one:
Table.SelectRows(FilteredYears, each Date.IsInPreviousNYears([Estimated delivery date], 2))
That is created in a step in Power Query, by going to the filter of the column "Estimated delivery date" ---> Date Filters --> Is in the previous --> 2 years
Thanks in advance!