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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

Return all values based on lookup table

Hello,

 

I recieve data logs, and one of the columns contains extremely long strings that are a combination of many different variables.  In an effort to parse out some of this data into usable pieces of information I am struggling to achieve the following (note, data is simplified for the example).

 

I have values that look like this:

ryanraff37_1-1622572256545.png

 

I want to lookup in this table to see if the string contains ANY of the values in this table:

ryanraff37_2-1622572306988.png

The ideal result would be:

ryanraff37_3-1622572331248.png


Now, the strings are much more complicated than the above, and the Key Values I want to parse out are 30+. Otherwise I might just use a few conditional columns and then concatenate them.

 

Not quite sure how to proceed and any help would be greatly aprpeciate.

 

Thanks!



 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

I will show you an other sample.

This time I get a sample from Excel.

1.png

Build a key table and create a key query list by this table.

Then let's add the lookup step in advance editor.

 

let
    Source = Excel.Workbook(File.Contents("...\Case Sample.xlsx"), null, true),
    Sheet10_Sheet = Source{[Item="Sheet10",Kind="Sheet"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Sheet10_Sheet,{{"Column1", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"String", type text}})
    ,
    Lookup = Table.AddColumn(#"Changed Type1", "Result", each Text.Combine(List.Accumulate(#"Key (2)", {}, (s,c) => if Text.Contains([String], c) then s&{c} else s), ","))
in
    Lookup

 

Change the code in red box. Result is as below.

2.png

Please Set Privacy as always ignore in Options.

3.png

Best Regards,

Rico Zhou

 

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

 

 

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous 

In addition to   's reply,  's code has three steps: 1. load the source 2. build a Key query 3. lookupvalue from key in String column.

Your actual table may be complex, so build a key query by yourself is not a good idea.

Try to build a key value table ,right click the column and add key column as new query. Key(2) is our query list.

1.png

Then copy this Lookup code and paste it behind source code, don't forget to add ",".

In lookupcode Key(2) after List.Accumulate is our query list name and [column1] is column name in Table like string.

let
Source = ...
...    ,
Lookup = Table.AddColumn(Source, "Result", each Text.Combine(List.Accumulate(Key(2), {}, (s,c) => if Text.Contains([Column1], c) then s&{c} else s), ","))
in
    Lookup

Result is as below. Please make sure all key value is in query list.

2.png

Best Regards,

Rico Zhou

 

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

 

 

 

Anonymous
Not applicable

Thank you for the response!

I unfortunately couldn't get this to work quite right.  My results column kept throwing an error, and when I tried to just recreate the above by uploading a single column table and single column key table to replicate the above I only managed to end up with blank values.

The strings in my table can be quite long, so not sure if that may be an issue.  Regardless, I apprecitae you taking the time to try and help me.  

Anonymous
Not applicable

Hi @Anonymous 

I will show you an other sample.

This time I get a sample from Excel.

1.png

Build a key table and create a key query list by this table.

Then let's add the lookup step in advance editor.

 

let
    Source = Excel.Workbook(File.Contents("...\Case Sample.xlsx"), null, true),
    Sheet10_Sheet = Source{[Item="Sheet10",Kind="Sheet"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Sheet10_Sheet,{{"Column1", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"String", type text}})
    ,
    Lookup = Table.AddColumn(#"Changed Type1", "Result", each Text.Combine(List.Accumulate(#"Key (2)", {}, (s,c) => if Text.Contains([String], c) then s&{c} else s), ","))
in
    Lookup

 

Change the code in red box. Result is as below.

2.png

Please Set Privacy as always ignore in Options.

3.png

Best Regards,

Rico Zhou

 

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

 

 

 

Anonymous
Not applicable

If you hadn't posted the privacy settings I'd have been stuck forever. Thank you, thank you, thank you!! I beleive because I am working with sharepoint files that those settings needed to be shifted. Works beautifully!

Anonymous
Not applicable

Thanks for the reply @CNENFRNL !

Unfortunately the strings I put in my above example were just to show what I was hoping to accomplish. The actual strings and lookup values are quite different (and very complex/long strings).  I'm not sure how to repurpose the above solution to use with the actual data I have (which I unfortunately cannot share due to privacy policy).

thanks!

CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSsnJNtbJSQ5OTc9NzSsxUkhMyUnPSXQvyi8tMFSK1YlWCgYCiKSJDljYKDkxJwUsBVFlZGxiqgNTkpyTaK0UGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [String = _t]),
    Key = {"Segment1","Segment2","Segment3","Segment4","Group1","Group2"},
    Lookup = Table.AddColumn(Source, "Result", each Text.Combine(List.Accumulate(Key, {}, (s,c) => if Text.Contains([String], c) then s&{c} else s), ","))
in
    Lookup

Screenshot 2021-06-01 205315.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors