Forum Discussion
Need Help : Getting column data from one table to other with no relation between those tables,
- 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
hi, Anonymous
1. rename Planned_Start_Date to Sprint_Start_Date
2. combine tables together
3. sort by Sprint_Start_Date (order ascending) and Index (descending)
4. Fill down Sprint_ID column
5. Filter Task_ID <> null
HI. Thanks AlienSx
for your response, but this solution is giving only matching rows from both tables, where Planned_Start_Date = Sprint_Start_Date,, but few Planned_Start_Date (Sprint_Start_Date) falls in between Sprint_Start_Date & Sprint_End_Date. I am not getting Sprint_ID for those rows. Can you give some eloborated solution, I am new to Power BI .
Thanks
Srinivas
- AlienSx2 years agoSuper User
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