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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
tengels
New Member

Compare values in 2 colums return value from 3rd column in a new colum

Hi all,

 

Trying to get my head around the following in Power Query.

I'm trying to compare 2 columns from 2 seperate table to find a common value

 

I have table Shipment_Data with column Consol ID and table Consol_Data with colum Reference.

The values in column Reference should be contained in the colum Consol ID, if it matches it should then copy the value from table Consol_Data, column MAWB from the same row and create a new column in table Shipment_Data with the respective value from table Consol_Data, column MAWB

 

As there might be multiple values in column Consol ID.

 

tengels_0-1669382128503.png

tengels_1-1669382167442.png

 

 

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @tengels ,

I created some data:

Shipment_Data:

vyangliumsft_0-1669614507204.png

Consol_Data:

vyangliumsft_1-1669614507205.png

 

Here are the steps you can follow:

1. Copy Shipment_Data in Power Query to form a Copy Table.

vyangliumsft_2-1669614507205.png

2. Home – Check [Consol ID] – Split Column – By Delimiter.

vyangliumsft_3-1669614507208.png

3. Check [Consol ID.1] and [Consol ID.2] - Transform - Unpivot Column.

vyangliumsft_4-1669614507210.png

Result:

vyangliumsft_5-1669614507210.png

4. Create calculated column.

Flag =
MAXX(FILTER(ALL(Copy),
'Consol_Data'[Reference] = 'Copy'[Value]),[MAWB])

5. Result:

vyangliumsft_6-1669614507211.png

 


Best Regards,

Liu Yang

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

Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Table1:

Master BillConsol ID
07457342331C2202200835
00171664994C2202374237
36984573355C2202200792
07146058036C2202377395
07146058036C2202377395
07146058036C2202377395
07457341723C2202200744
61535930031C2202200700
C2202364686C2202200729, C2202364686
07146058036C2202377395
71632345806C2202158469
07146054260C2202181411, C2202200735
61828220091C2202158831
50112781812C2202377481
07146051036C2202200770, C2202417899
61828220091C2202158831
61828220091C2202158831
S0225112022VIEC2201709488, C2202200835, C2202419076
S0225112022VIEC2201709488, C2202200835, C2202419076
S0225112022VIEC2201709488, C2202200835, C2202419076
S0225112022VIEC2201709488, C2202200835, C2202419076
S0225112022VIEC2201709488, C2202200835, C2202419076
S0225112022VIEC2201709488, C2202200835, C2202419076
S0225112022VIEC2201709488, C2202200835, C2202419076
07146054260C2202181411, C2202200735

Table 2

ReferenceMaster Bill
C220220072207146051972
C220220077407146052020
C220220083707146052075
C220216150117652177974
C220215846761828220581
C220216149017652191716
C220215872817652191731
C220215868561828220356
C220237747350112781414
C220237751250112781451
C220237380087641125512
C220237742850112782814
C220241169711266136582
C220220077507146050885
C220220077007146051036
C220229852207146056205
C220220076507146053615
C220220073307146053431
C220237748150112781812
C220237749850112781392
C220237830750112781403
C220237743650112781440
C220237764750112782803
C220215843707756796294
C220215845215786602025
C220215848607756803165
C220215847607756803250
C220215877261828219951
C220215883161828220091
C220215846415787404634
C220215877915787422274
C220215850893315611470
C220223578407146053361
C220241867807146049872
C220220073507146054260
C220215858715786602176
C220215882315786602434
C220215872261827740484
C220215878361828219984
C220215856561828220393
C220215874261827740930
C220215886161828220286
C220215846971632345806
C220215850029784162982
C220220638461532398236
C220238992761535931350
C220220081161535929961
C220241142461535929681
C220220081461535930646
C220220070461535928384
C220220081361535931206
C220220066861535929935
C220220083961535928955
C220220073161535928513
C220220074261535928944
C220220078661535930016
C220220068361535931453
C220220071561535928970
C220220070061535930031
C220220066161535928852
C220210274201693617204
C220220080736984573145
C2202374331001
C220237423700171664994
C220237426400171308241
C220240979236984556032
C220220079336984573171
C220239976336984555962
C220220079236984573355
C220220072936984573300
C220220082907457341443
C220220083507457342331
C220237740407146963792
C220237739407146058025
C220237739507146058036
C220237761107146057944
C220220074407457341723

End result for table 1:

Master BillConsol ID
07457342331C2202200835
00171664994C2202374237
36984573355C2202200792
07146058036C2202377395
07146058036C2202377395
07146058036C2202377395
07457341723C2202200744
61535930031C2202200700
36984573300C2202200729
07146058036C2202377395
71632345806C2202158469
07146054260C2202200735
61828220091C2202158831
50112781812C2202377481
07146051036C2202200770
61828220091C2202158831
61828220091C2202158831
07457342331C2202200835
07457342331C2202200835
07457342331C2202200835
07457342331C2202200835
07457342331C2202200835
07457342331C2202200835
07457342331C2202200835
07146054260C2202200735

So in the end it should pick the corresponding value of Master Bill from Table 2 depending on which Consol ID value in Table 1 matches the Reference value in table 2

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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