Forum Discussion
Maricel
4 years agoFrequent Visitor
Is possible to filter dates in Power query using "the last 12 months"?
Hello, I'm trying to create a new table which should contain the avarage price for an item based in the buying prices gotten in the last year o in the last x period. The table I'm using as re...
- 4 years ago
Hi Maricel ,
You can use the GUI to filter last 12 complete months (i.e. not current month) like this:
Which generates the code
Date.IsInPreviousNMonths([date], 12)Or you can create a step like this if you want last 12 months rolling (including current month):
= Table.SelectRows(previousStep, each [date] >= Date.AddMonths(Date.From(DateTime.LocalNow()), -12))Pete
Greg_Deckler
Community Champion
4 years agoMaricel Yes, you can use Date.From (DateTime.LocalNow ()) to get the current Date and then you can just get the last year from there.