In Excel, Expand All Combinations of Multiple Columns
Judith-Excel-Sharing
Posted on June 12, 2024
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.
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:
Solution:
Use SPL XLL to enter the following formula:
=spl("=E@b(?.(~.(~.split@c())).conj(eval($[xjoin(] / ~.($[~(] / # / $[)]).concat($[;]) / $[)])))",A2:G4)
As shown in the picture below:
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 "";"".
Posted on June 12, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.