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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Craigo
Regular Visitor

Using a comma separated column to lookup a value in another unrelated table

Hello. I have one table with comma separated column and I want to look up each value in another unrelated table and if it exists, get the value from a different column in that second table and create a new column in the first table. For example (this is a VERY simplified version of what Im after), I have a table

Craigo_3-1691143974018.png

 

And I want to take each of the “Sales_Codes” and look for them in the “item_code” column in the table below and if it exists in “item_code”, return the “item_desc”

Craigo_4-1691143993777.png

 

So the result would look like

Craigo_5-1691144009242.png

 

Because of the ways the tables are created, there would never be a possibility of an ID being more than one of the “item_desc” values (i.e 453124 would only be “car” and nothing else, but I have to look it up to know that it is “car”). Any help with this would be greatly appreciated.

1 ACCEPTED SOLUTION

Mate, that works brilliantly. I'll do some more testing with a slightly more complex set of tables, but I think this will work. Thanks very much for your help.

View solution in original post

3 REPLIES 3
barritown
Super User
Super User

Hi @Craigo,

There is also such an option:

- split the comma separated lists in the [Item_Code] column of your second table into separate rows using this solution - https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-with-comma-delimit...

- once done, the following calculated column does the rest:

Item_desc = 
MINX ( FILTER ( Ref, CONTAINSSTRING ( [Sales_Code], [Item_Code] ) ), [Item_desc] )

 

barritown_0-1691396008173.png

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Mate, that works brilliantly. I'll do some more testing with a slightly more complex set of tables, but I think this will work. Thanks very much for your help.

v-tangjie-msft
Community Support
Community Support

Hi @Craigo ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create calculated columns.

 

PATH = SUBSTITUTE([Sales_Code],",","|")
PATH_1 = PATHITEM([PATH],1)
PATH_2 = PATHITEM([PATH],2)
PATH_3 = PATHITEM([PATH],3)
Item_desc = MAXX(FILTER(Table2,CONTAINSSTRING([Item_Code],EARLIER(Table1[PATH_1]))||IF(EARLIER(Table1[PATH_2])<>BLANK(),CONTAINSSTRING([Item_Code],EARLIER(Table1[PATH_2])))||IF(EARLIER(Table1[PATH_3])<>BLANK(),CONTAINSSTRING([Item_Code],EARLIER(Table1[PATH_3])))),[Item_desc])

 

(3) Then the result is as follows.

vtangjiemsft_0-1691393605050.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.