Find difference between two strings

In the Excel table below, both column A and column B contain semicolon-separated strings:


A

B

1

Tom;Hema

Tom

2

Tom;Hema;Alice;Liam

Tom;Alice

3

Tom;Hema

Tom;Hema

Task: Find difference between column A and column B, which consists of items that are contained in column A but not contained column B, and separate the result with the semicolon:


D

1

Hema

2

Hema;Liam

3


Use SPL XLL to get this done:

=spl("=?.((~1.split($[;]) \ ~2.split($[;])).concat($[;]))",A1:B3)

Picture1png


~1 represents the first child member of the current member (row); \ is the operator for computing the difference; $[] represents a string.

Source:https://stackoverflow.com/questions/78153544/ive-2-columns-ex-in-column-a-tom-hema-and-in-column-b-tom-so-in-column-c-i-n