Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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 reference has: ID product, Prices, buying's Date.
In this table a ID product has diferrents prices (because of the date, the supliers, etc).
I need to create a master table that only contains ID Product and the avarage price por that item, using only the prices gotten in the last year to avoid mistakes or an avarage price that has no sense.
Is it possible to do so using power query? How can I do that kind of table? Get the avarage prices and not including past dates?
Solved! Go to Solution.
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
Proud to be a Datanaut!
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
Proud to be a Datanaut!
@Maricel Yes, you can use Date.From (DateTime.LocalNow ()) to get the current Date and then you can just get the last year from there.
User | Count |
---|---|
9 | |
8 | |
6 | |
6 | |
6 |