If List 1 match with any in List 2 then true

mduntley

Board Regular
Joined
May 23, 2015
Messages
139
Office Version
  1. 365
Platform
  1. Windows
Below is my M code, I am trying to add a column to show if List 1 match with anything in list 2. I am expecting the first line to be true and the last 2 to be false

Power Query:
let
    Cities = Table.FromRows({{"New York", "Los Angeles", "Chicago", "Red", "Orange", "Yellow", "New York"},
                             {"Miami", "Houston", "Dallas", "Blue", "Purple", "Pink", "Brown"},
                             {"Phoenix", "Philadelphia", "San Antonio", "Black", "White", "Gray", "Turquoise"}}),
    #"Added Custom" = Table.AddColumn(Cities, "Custom", each {[Column1],[Column2],[Column3]}),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each {[Column4],[Column5],[Column6],[Column7]}),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom1",{"Custom", "Custom.1"})
in
    #"Removed Other Columns"
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Power Query:
let
    Cities = Table.FromRows({{{"New York", "Los Angeles", "Chicago"}, {"Red", "Orange", "Yellow", "New York"}},
                             {{"Miami", "Houston", "Dallas"}, {"Blue", "Purple", "Pink", "Brown"}},
                             {{"Phoenix", "Philadelphia", "San Antonio"}, {"Black", "White", "Gray", "Turquoise"}}}),
    Result = Table.AddColumn(Cities, "AnyMatch?", each List.ContainsAny([Column1],[Column2]))
in
    Result
 
Upvote 1
Solution

Forum statistics

Threads
1,223,882
Messages
6,175,165
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top