Forum Discussion
Anonymous
3 years agoNot applicable
Combine two tables based on date ranges.
I'm not sure if anyone is able to assist to combine two tables based on different date ranges or having a lookup in dax to add values to an existing table based on date ranges. This has to do with fo...
- 3 years ago
Anonymous make sure you use correct dates (you have 31st of April in your data). Also make sure you have dates in rates table earlier than min date in GL table. Replace your_rates_table and your_GL_table in code below with correct references to your tables.
let // this is your table with rates. Had to trim ccy column later. s_rates = your_rates_table, date_type = Table.TransformColumnTypes(s_rates, {{"Effective Date", type date}}, "en-AU"), trimmed = Table.TransformColumns(date_type,{{"From Currency", Text.Trim, type text}}), // this is your table with amounts before = your_GL_table, b_type = Table.TransformColumnTypes(before, {{"GL Date", type date}}, "en-AU"), // make a record with ccy name fields and list of dates and rates sorted by date rates = Table.Group( trimmed, "From Currency", {{"rates", each List.Sort( List.Zip({_[Effective Date], _[Multiplier]}), {(x) => x{0}, Order.Descending})}} ), rec = Record.FromList(rates[rates], rates[From Currency]), // add Multiplier column. after = Table.AddColumn( b_type, "Multiplier", each [a = Record.FieldOrDefault(rec, [Base Currency], null), b = a{List.PositionOf(a, [GL Date], Occurrence.First, (x, y) => x{0} <= y)}, c = if b = -1 then null else b{1}][c] ) in after
Anonymous
3 years agoNot applicable
This works well but does cause having a duplicate table with the same transactional information and cannot delete the orginal table.
Is there a way to combine the s_rates into the table with the amounts so that before read the table with the amounts