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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
o-johnralphp
New Contributor

Look for Values from 2 Columns in a Separate Table

Hi Everyone,

 

I have 2 separate table (Table1 and Table2) and would like to create a calculated column on the Table1 to return the value based on Table2 2columns.

Table1
InvoiceItemsDesired Output
12345Banana apple grapes orangePackage1,Package2
123456apple orangeNo Match
123457Banana orange applePackage2

 

Table 2
PackageTypeItemAItemB
Package1grapesorange
Package 2bananaorange

 

Many thanks  for the help.

 

 

 

1 ACCEPTED SOLUTION
rohit1991
Honored Contributor

Hi @o-johnralphp 

You can do this using a calculated column in Table1 that checks both ItemA and ItemB from Table2 and returns all matching package names.

 

Claculated column (Table1):

Desired Output =
VAR txt = LOWER('Table1'[Items])
VAR match =
   ADDCOLUMNS (
       'Table2',
      "@pkg",
       IF (
          CONTAINSSTRING ( txt, LOWER('Table2'[ItemA]) ) &&
           CONTAINSSTRING ( txt, LOWER('Table2'[ItemB]) ),
          'Table2'[PackageType]
       )
   )
VAR result =
   CONCATENATEX ( FILTER ( match, [@pkg] <> BLANK() ), [@pkg], ", " )
RETURN IF ( result = BLANK(), "No Match", result )

image.png

 


Did it work? โœ” Give a Kudo โ€ข Mark as Solution โ€“ help others too!

View solution in original post

2 REPLIES 2
rohit1991
Honored Contributor

Hi @o-johnralphp 

You can do this using a calculated column in Table1 that checks both ItemA and ItemB from Table2 and returns all matching package names.

 

Claculated column (Table1):

Desired Output =
VAR txt = LOWER('Table1'[Items])
VAR match =
   ADDCOLUMNS (
       'Table2',
      "@pkg",
       IF (
          CONTAINSSTRING ( txt, LOWER('Table2'[ItemA]) ) &&
           CONTAINSSTRING ( txt, LOWER('Table2'[ItemB]) ),
          'Table2'[PackageType]
       )
   )
VAR result =
   CONCATENATEX ( FILTER ( match, [@pkg] <> BLANK() ), [@pkg], ", " )
RETURN IF ( result = BLANK(), "No Match", result )

image.png

 


Did it work? โœ” Give a Kudo โ€ข Mark as Solution โ€“ help others too!

Thank you very much!!! 

Helpful resources

Announcements
Users online (26)