Sheet containing 1000+ product SKUs, and ~4000 images. Not every SKU will have the same number of images.
Right now, it lists 1 image per line:
SKU001 Image001_1.jpg
SKU001 Image001_2.jpg
SKU001 Image001_3.jpg
SKU002 Image002_1.jpg
SKU002 Image002_2.jpg
SKU003 Image003_1.jpg
…and so on.
In order to import these products into WooCommerce, I need to provide a comma-separated list of images for each SKU:
SKU001 Image001_1.jpg,Image001_2.jpg,Image001_3.jpg
SKU002 Image002_1.jpg,Image002_2.jpg
SKU003 Image003_1.jpg
I know how to use the TRANSPOSE function, manually. I also know how to use TEXTJOIN to combine cells that are already listed horizontally.
What I don’t know is how to do it automatically by SKU.
I.e. read Column A, and TRANSPOSE all items in Column B until the value in Column A changes.
I’m sure there’s something with COUNTIF, TRANSPOSE, FILTER, or a combination thereof, but everything I’ve tried so far, failed.
Any suggestions?
3
Answers
OK, figured it out :)
It's a 3-step solution but it's a MUCH simpler formula.
Step 1: isolate the SKUs (1 unique instance of each) - make a new column/sheet, and put the following formula in it:
(where "A" is the column containing the SKUs).
This gives us a list that looks like:
Step 2: now that we have ONE unique SKU, we can use it to (1) filter out results from Column B (Condition 1) as long as they parallel the value in Column A that matches to the value of the current line in Column D (Condition 2)... and (2) transpose the results horizontally:
We put this formula into Column E, and copy it down so Sheets auto-increments the value D1, D2, D3, etc:
To put it another way: FILTER "reads Column B WHILE Column A equals D1". And then the resulting list of values from Column B is turned 90 degrees and written out horizontally.
Results:
So now, we have a list of image URLs listed horizontally, 1 per cell. But we need a combined list, comma-separated. This is where TEXTJOIN comes in.
Step 3: find the next completely empty column (no image URLs), for example Column M, and use:
TEXTJOIN takes a delimiter (in this case comma, ","), has an option to skip empty cells (TRUE), and then a range (E1 through L1).
Result (Column M):
...which is exactly what was needed for a WooCommerce import.
The benefit of this is that you can see the intermediate steps, it's easier to troubleshoot, and you also yield a filtered list of SKUs in case you need it for a catalog or something.
try:
This extract only from SKU: