Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not 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 

Task_Table.jpg

2. Sprint Table,

Sprint_Table.jpg

 

 

 

 

 

 

 

 

 

 

I would like to bring Sprint_ID from Sprint table to Task Table as a new column as shown below based on the condition if Planned_Start_Date falls in to which Sprint Start & End Dates. And there is no relation between these two tables. Can anyone suggest how this can be acheived in power Query or DAX.

3. Result table 

Task_Table (Sprint).jpg

Can someone help me , how to get it.

Thanks

Srinivas

2 ACCEPTED SOLUTIONS

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

View solution in original post

dufoq3
Super User
Super User

Hi @Anonymous,

Result:

dufoq3_0-1706989921425.png

 

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

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

8 REPLIES 8
dufoq3
Super User
Super User

Hi @Anonymous,

Result:

dufoq3_0-1706989921425.png

 

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

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Anonymous
Not applicable

HI @dufoq3, I tried the solution you have given, its working. both solutions given by you and @AlienSx are working. Thanks for your support.

Anonymous
Not applicable

Hi @dufoq3 @AlienSx  , Thanks for your response.
in My requirement, the task_table would be dynamically growing as the time progress as well Sprint_table, let's say tasks will keep increasing (data in Task_table is fetched from excel ) like TS_20.....TS_30....TS_35 etc...and the these tasks will fall into subsequent sprints (between Sprint_Start_Date & Sprint_End_Date) based on their Planned_Start_dates. for other project(s)..the sprint_table would containg different start & end dates.

I am looking for a generalized solution which can be used across projects. I understood from your solution that, it works for a fixed number of  rows in task_table. Hope my understanding is right and put my requirement rightly..

 

Thanks

Srinivas

@Anonymous replace #table function calls with references to your task and sprint tables accordingly. 

AlienSx
Super User
Super User

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

Anonymous
Not applicable

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

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
Anonymous
Not applicable

Hi @AlienSx Thanks for your help. With referncecing I could able to do it..

also @dufoq3 thanks for your support.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.