Forum Discussion
Anonymous
2 years agoNot applicable
Need Help : Getting column data from one table to other with no relation between those tables,
Hi, I have two Tables 1. Task Table 2. Sprint Table, I would like to bring Sprint_ID from Sprint table to Task Table as a new column as shown below base...
- 2 years ago
don't know what solution you are talking about. My solution works just fine. Next time post some data we can grab from your message, not images.
let task_table = #table( {"Task_ID", "Planned_Start_Date"}, {{"TS_1", #date(2023, 9, 20)}, {"TS_2", #date(2023, 9, 29)}, {"TS_3", #date(2023, 10, 20)}, {"TS_4", #date(2023, 10, 8)}} ), sprint_table = #table( {"Sprint_Start_Date", "Spint_End_Date", "Index", "Sprint_ID"}, {{#date(2023, 9, 18), #date(2023, 10, 1), 1, "S1"}, {#date(2023, 10, 2), #date(2023, 10, 15), 2, "S2"}, {#date(2023, 10, 16), #date(2023, 10, 29), 3, "S3"}} ), rename = Table.RenameColumns(task_table, {"Planned_Start_Date", "Sprint_Start_Date"}), combine = sprint_table & rename, sort = Table.Sort(combine,{{"Sprint_Start_Date", Order.Ascending}, {"Index", Order.Descending}}), fill_down = Table.FillDown(sort,{"Sprint_ID"}), filter = Table.SelectRows(fill_down, each ([Task_ID] <> null))[[Task_ID], [Sprint_Start_Date], [Sprint_ID]], z = Table.RenameColumns(filter, {"Sprint_Start_Date", "Planned_Start_Date"}) in z - 2 years ago
Hi Anonymous,
Result:1.) Delete whole code in 1st step task_table step and replace it with your task_table reference
2.) do the same for 2nd step sprint_table
let task_table = #table( {"Task_ID", "Planned_Start_Date"}, {{"TS_1", #date(2023, 9, 20)}, {"TS_2", #date(2023, 9, 29)}, {"TS_3", #date(2023, 10, 20)}, {"TS_4", #date(2023, 10, 8)}} ), sprint_table = #table( {"Sprint_Start_Date", "Sprint_End_Date", "Index", "Sprint_ID"}, {{#date(2023, 9, 18), #date(2023, 10, 1), 1, "S1"}, {#date(2023, 10, 2), #date(2023, 10, 15), 2, "S2"}, {#date(2023, 10, 16), #date(2023, 10, 29), 3, "S3"}, {#date(2023, 10, 30), #date(2023, 11, 12), 4, "S4"}, {#date(2023, 11, 13), #date(2023, 11, 26), 5, "S5"}, {#date(2023, 11, 27), #date(2023, 11, 10), 6, "S6"}}), Ad_Sprint_ID = Table.AddColumn(task_table, "Sprint_ID", each Table.SelectRows(sprint_table, (x)=> x[Sprint_Start_Date] <= [Planned_Start_Date] and x[Sprint_End_Date] >= [Planned_Start_Date]){0}[Sprint_ID]) in Ad_Sprint_ID
dufoq3
2 years agoCommunity Champion
Hi Anonymous,
Result:
1.) Delete whole code in 1st step task_table step and replace it with your task_table reference
2.) do the same for 2nd step sprint_table
let
task_table = #table(
{"Task_ID", "Planned_Start_Date"},
{{"TS_1", #date(2023, 9, 20)},
{"TS_2", #date(2023, 9, 29)},
{"TS_3", #date(2023, 10, 20)},
{"TS_4", #date(2023, 10, 8)}}
),
sprint_table = #table(
{"Sprint_Start_Date", "Sprint_End_Date", "Index", "Sprint_ID"},
{{#date(2023, 9, 18), #date(2023, 10, 1), 1, "S1"},
{#date(2023, 10, 2), #date(2023, 10, 15), 2, "S2"},
{#date(2023, 10, 16), #date(2023, 10, 29), 3, "S3"},
{#date(2023, 10, 30), #date(2023, 11, 12), 4, "S4"},
{#date(2023, 11, 13), #date(2023, 11, 26), 5, "S5"},
{#date(2023, 11, 27), #date(2023, 11, 10), 6, "S6"}}),
Ad_Sprint_ID = Table.AddColumn(task_table, "Sprint_ID", each Table.SelectRows(sprint_table, (x)=> x[Sprint_Start_Date] <= [Planned_Start_Date] and x[Sprint_End_Date] >= [Planned_Start_Date]){0}[Sprint_ID])
in
Ad_Sprint_ID