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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Yester07
Frequent Visitor

Search value in another table and retrieving data

Hello,

I have a complicated request. I want to check if the value of column B exists in column A. If it exists, I want to replace the value in the same rows of the column "COL D-B" with the value of the column "Col C-A". Hope it is clear I am new to Power Query and I tried for a few days...

 

Table : 

Col ACol B Col C-ACol D-B
AZDFDesc A1Desc B1
AZEAZDesc A2Desc B2
AZERAZERTDesc A3Desc B3
AZERTFDDesc A4Desc B4

 

Results : 

Col ACol B Col C-ACol D-B
AZDFDesc A1Desc A2
AZEAZDesc A2Desc B2
AZERAZERTDesc A3Desc B3
AZERTFDDesc A4Desc A3

 

For now, I added a column that put "True" if the value is found, and I also tried to put the column "Col B" and the col "Col D-B" in another table, in vain.

 

Thank you.

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcoxS0lFycQMRqcXJCo6GMJaToVKsDkjeFSgCUQVWYARXYARTEARW4RoUAldkDFdkDFcEknVzgSsxgSsxUYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col A" = _t, #"Col B" = _t, #"Col C-A" = _t, #"Col D-B" = _t]),
    ColBBuffList = Source[Col B],
    #"Added Custom" = Table.ReplaceValue(Source,each [#"Col D-B"],each if List.Contains(ColBBuffList,[Col A]) then Source[#"Col C-A"]{List.PositionOf(ColBBuffList,[Col A])} else [#"Col D-B"],Replacer.ReplaceValue,{"Col D-B"})
in
    #"Added Custom"

 

View solution in original post

2 REPLIES 2
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcoxS0lFycQMRqcXJCo6GMJaToVKsDkjeFSgCUQVWYARXYARTEARW4RoUAldkDFdkDFcEknVzgSsxgSsxUYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col A" = _t, #"Col B" = _t, #"Col C-A" = _t, #"Col D-B" = _t]),
    ColBBuffList = Source[Col B],
    #"Added Custom" = Table.ReplaceValue(Source,each [#"Col D-B"],each if List.Contains(ColBBuffList,[Col A]) then Source[#"Col C-A"]{List.PositionOf(ColBBuffList,[Col A])} else [#"Col D-B"],Replacer.ReplaceValue,{"Col D-B"})
in
    #"Added Custom"

 

OMG, thank you so much !!
PS: I just changed the name of the columns, applied a filter, then create 2 other sources.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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