Compare Two Delimited Lists and Determine if Values are the Same

thestranger66

New Member
Joined
Nov 11, 2015
Messages
22
Hello,

I am trying to come up with a function that compares two delimited lists to see if they are made up of the same values. Each list is in its own cell, can be variable length, and can have variable order. I'll give a few examples of inputs and outputs to display what I am trying to accomplish with my worksheet function below.

List 1List 2Output
A; BAF
A; B; 1A; BF
AA; BF
B; AA; BT
A; BA; BT

The best I've been able to come up with so far is to use a series of helper columns that returns individual values from each list so that they can be individually counted, but this isn't ideal since the lists can be around 8 items long and performance is an important factor for this solution. Thanks in advance to anyone who take the time to think through this.

-Steve
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try:

Book1
ABC
1List 1List 2Output
2A; BAFALSE
3A; B; 1A; BFALSE
4AA; BFALSE
5B; AA; BTRUE
6A; BA; BTRUE
7Cat; Dog; Mousedog;mouse;catTRUE
8Boat; car; motorcyclemoped; boat; car; motorcycleFALSE
Sheet10
Cell Formulas
RangeFormula
C2:C8C2=AND(PRODUCT(--ISNUMBER(SEARCH(TRIM(MID(SUBSTITUTE(B2,";",REPT(" ",999)),999*{1,2,3,4,5,6,7,8}-998,999)),A2))),PRODUCT(--ISNUMBER(SEARCH(TRIM(MID(SUBSTITUTE(A2,";",REPT(" ",999)),999*{1,2,3,4,5,6,7,8}-998,999)),B2))))
 
Last edited:
Upvote 0
Here is a way using Power Query.

Book1
ABC
1List 1List 2Output
2A;BAFalse
3A;B;1A;BFalse
4AA;BFalse
5B;AA;BTrue
6A;BA;BTrue
7Cat;Dog;MouseDog;Mouse;CatTrue
8Boat;Car;MotorcycleMoped;Boat;Car;MotorcycleFalse
Sheet2


Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ProperCase = Table.TransformColumns(Source,{{"List 2", Text.Proper, type text}, {"List 1", Text.Proper, type text}}),
    #"86Spaces" = Table.ReplaceValue(ProperCase," ","",Replacer.ReplaceText,{"List 1", "List 2"}),
    Output = Table.AddColumn(#"86Spaces", "Output", each List.Sort(Text.Split([List 1],";"))=List.Sort(Text.Split([List 2],";")))
in
    Output
 
Upvote 0
Sorry for the delay in responding to this.

I ended up using Eric W.'s solution as I was looking for a worksheet formula and am not familiar with PowerQuery.

Thanks for the input!
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,123
Members
453,021
Latest member
Justyna P

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