Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
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 |
7100000 | 7200000 | INFO 1 |
7000000 | 7099999 | INFO 2 |
7300000 | 7399999 | INFO 3 |
table2
ID | Name | NEW COLUMN NEEDED |
7101010 | SOMEONE | INFO 1 |
7302202 | NEW PERSON | INFO 3 |
7033300 | DOG | INFO 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.
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.
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.
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)
Hi @hugomatos
Can you please try the below DAX.
Hi,
Please check the below picture and the attached pbix file.
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.
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