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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rauerfc
Frequent Visitor

Search if values exist in another table and returning values from column (Power query Editor)

Hi, I have one table A and a cross-reference table = "table B" that I want to return Value from column "SU".

 

Table A:

Customer Consignee Reported KeyTypeLoc
22137AAS
9878BDAS
23563CDG
6322DASD
26468EAS
13473SD
14739FGF
18831DASD
18196EA
26551FFG
23236GHASDASD
20749SASD
11952AC

 

Table B:

Customer Consignee Reported KeySU
26468154
26468555
13473483
14739120

 

First I checked if the value exists in Table B:

 

 

if List.Contains(Cross_ref[Customer], [Customer Consignee Reported Key]) = true then

 

 

If True I want to return the value from "SU" column like a lookup function? Is this possible?

If false the script will search using another column from data frame.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rauerfc ,

 

As @lbendlin said, you may try Merge to replace M syntax in Power Query. Belowis my method, please check.

 

Since there are two values for Customer 26468——154 and155, I transformed the Table B by using Table.Group() and Text.Combine() firstly:

#"Grouped Rows" = Table.Group(#"Changed Type" , {"Customer"}, {{"Combine Values", each Text.Combine(List.Transform(_[SU], (x) => Number.ToText(x)), " , "), type text}})

transform Table B.PNG

 

Then please use the following formula to create a new custom column to Table A:

try (let currentCustomer = [Customer Consignee Reported Key] in Table.SelectRows(#"Table B", each [Customer] = currentCustomer)){0}[Combine Values] otherwise "No matched"

The final output is shown below:

Find matched values from another table.PNG

 

Best Regards,
Eyelyn Qin
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

2 REPLIES 2
Anonymous
Not applicable

Hi @rauerfc ,

 

As @lbendlin said, you may try Merge to replace M syntax in Power Query. Belowis my method, please check.

 

Since there are two values for Customer 26468——154 and155, I transformed the Table B by using Table.Group() and Text.Combine() firstly:

#"Grouped Rows" = Table.Group(#"Changed Type" , {"Customer"}, {{"Combine Values", each Text.Combine(List.Transform(_[SU], (x) => Number.ToText(x)), " , "), type text}})

transform Table B.PNG

 

Then please use the following formula to create a new custom column to Table A:

try (let currentCustomer = [Customer Consignee Reported Key] in Table.SelectRows(#"Table B", each [Customer] = currentCustomer)){0}[Combine Values] otherwise "No matched"

The final output is shown below:

Find matched values from another table.PNG

 

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

lbendlin
Super User
Super User

What do you expect to happen for 26468 ? It has two matches in Table B.

 

You don't need to do lookups in Power Query. You do merges, or custom column generators.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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