In Excel, Expand All Combinations of Multiple Columns

Problem description & analysis:

In the following Excel table, column A contains codes and the other columns are grouping columns having different meanings and containing comma-separated values.

table 1

The computing goal: split each grouping column value to generate a row for each unique combination. Below is the expansion result of the first record:

expansion result of the first record

Solution:

Use SPL XLL to enter the following formula:

=spl("=E@b(?.(~.(~.split@c())).conj(eval($[xjoin(] / ~.($[~(] / # / $[)]).concat($[;]) / $[)])))",A2:G4) 
Enter fullscreen mode
Exit fullscreen mode

As shown in the picture below:

result table with code entered
Explanation:

E@b()function converts each row, except for the column header row, to a sequence. split@c splits a string into a comma-separated sequence. conj() function concatenates members of each sequence. eval()function takes the string as the dynamic code to execute. xjoin() performs cross-product on multiple sequences to combine them. $[;] is the simplified form of writing a string, which is equivalent to “”;””.


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Screen reader users also get automatic announcements to turn the screen reader mode on as soon as they enter the website. Get food delivery to your doorstep. Step 5 : utilize keyword research tools.