Forum Discussion
Hidde
Helper I
8 years agoGet value/price from one date earlier
Hi I can't figure it out, tried some things. So I have a date table with all dates (called DATES) and a product table where for every product & new price there's a row. So whenever a product chan...
Gazzer
Resolver II
8 years agoNot the most elegant solution, but it seems to work.
Sort your table by Product Code and then Date.
Then add two index fields, one starting from 0 and the other from 1.
Merge as New with the same table, using the Product code and indexes to join (see image)
Then filter the Productcode column to get rill of null values, and remove the index columns.
let
Source = Table.NestedJoin(Table2,{"Productcode", "Index"},Table2,{"Productcode", "Index.1"},"Table2",JoinKind.FullOuter),
#"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {"Price"}, {"Table2.Price"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Table2", each ([Productcode] <> null)),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Productcode", "Price", "Date", "Table2.Price"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns",{{"Table2.Price", "Previous Price"}})
in
#"Renamed Columns"Like I said, not particularly clever, but might help you get the job done.
Hidde
Helper I
8 years agoThanks for the reply. However, the dat is in a data warehouse & changing constantly. I don't think its good to join every time...