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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
hugomatos
New Member

Creating new column based on value from another table

Hi everyone,

 

I have 2 tables and I need to create a column on the second based on values from the first. Some ideia? 

 

table1

START CODE       END CODE      INFO     
71000007200000INFO 1
70000007099999INFO 2
73000007399999INFO 3

 

table2

ID                    Name                           NEW COLUMN NEEDED                  
7101010SOMEONE INFO 1
7302202NEW PERSONINFO 3
7033300DOGINFO 2

 

I need to add a new column on table2 that comes from table1[info] using as criteria that Table2[ID] should be between table1[start code] and table1[end code] and then return table1[info] to be placed as a new column on table2.

Important: the ranges table1[start] and table1[end] are uniques.

 

Thanks.

3 ACCEPTED SOLUTIONS
d_m_LNK
Resolver III
Resolver III

You could create a calculated DAX Column on table 2 for this.  You would could create an ID for your code ranges and add them to your table1.  Then with your caclulated column calculate what ID to assign each row and then relate the ID of table1 to the calculated ID of table2 Something like:


VAR RowID = Table2[ID]
VAR FilteredTable =
FILTER('Table1',
AND('Table1'[StartCode] <= RowID,
'Table1'[EndCode] >=RowID
)
)
VAR Result =
CALCULATE(
DISTINCT('Table1'[IDRangeKey]), FilteredTable)
RETURN Result

 

Once that is created you can access that info column through the newly created relationship

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1742530493102.png

 

 

expected result CC = 
SUMMARIZE (
    FILTER (
        Table1,
        Table1[START CODE] <= Table2[ID]
            && Table1[END CODE] >= Table2[ID]
    ),
    Table1[INFO]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

mdaatifraza5556
Super User
Super User

Hi @hugomatos 

Can you please try the below DAX.

New Column =
VAR MatchingRow =
    FILTER(
        table1,
        Table1[START CODE ] <= Table2[ID] &&
        Table2[ID] <= Table1[END CODE ]
    )
RETURN
    MAXX(MatchingRow, Table1[INFO])


If you have found your answer, please mark it as the solution.

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @hugomatos,

Thanks for reaching out to the Microsoft fabric community forum.

It looks like you are looking for a way to add a column from one table to another. As @sevenhills@mdaatifraza5556@Jihwan_Kim and @d_m_LNK all responded to your query, please go through the responses and mark the helpful reply as solution.

 

I would also take a moment to thank @sevenhills@mdaatifraza5556, @Jihwan_Kim and @d_m_LNK for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.
Community Support Team

 

If this post helps then please mark it as a solution, so that other members find it more quickly.

Thank you.

Anonymous
Not applicable

Hi @hugomatos,

As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.

If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.


If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
Thank you for your patience and look forward to hearing from you.

Anonymous
Not applicable

Hi @hugomatos,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.


Thank you.

Anonymous
Not applicable

Hi @hugomatos,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

 

Thank you.

sevenhills
Super User
Super User

Try this, add column to Table2:

Column = SUMMARIZE( FILTER( Table1, Table2[ID] >= Table1[START CODE] && Table2[ID] <= Table1[END CODE]), Table1[INFO]) 

 

Output: (Table 2)

sevenhills_0-1742597223022.png

 

mdaatifraza5556
Super User
Super User

Hi @hugomatos 

Can you please try the below DAX.

New Column =
VAR MatchingRow =
    FILTER(
        table1,
        Table1[START CODE ] <= Table2[ID] &&
        Table2[ID] <= Table1[END CODE ]
    )
RETURN
    MAXX(MatchingRow, Table1[INFO])


If you have found your answer, please mark it as the solution.
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1742530493102.png

 

 

expected result CC = 
SUMMARIZE (
    FILTER (
        Table1,
        Table1[START CODE] <= Table2[ID]
            && Table1[END CODE] >= Table2[ID]
    ),
    Table1[INFO]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
d_m_LNK
Resolver III
Resolver III

You could create a calculated DAX Column on table 2 for this.  You would could create an ID for your code ranges and add them to your table1.  Then with your caclulated column calculate what ID to assign each row and then relate the ID of table1 to the calculated ID of table2 Something like:


VAR RowID = Table2[ID]
VAR FilteredTable =
FILTER('Table1',
AND('Table1'[StartCode] <= RowID,
'Table1'[EndCode] >=RowID
)
)
VAR Result =
CALCULATE(
DISTINCT('Table1'[IDRangeKey]), FilteredTable)
RETURN Result

 

Once that is created you can access that info column through the newly created relationship

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.