Home > other >  Convert a multi-list to a list of category items in Google Sheets
Convert a multi-list to a list of category items in Google Sheets

Time:10-05

How to convert this unrelated multi-list "unrelated columns"

Category1   Category2   Category3   ...
Items...    Items...    Items...    ...
Bags Shoes Jewelry
Purses Sneakers or tennis shoes Necklaces
Shoulder bags Flats
Crossbody bag Flip flops Earrings

To this, with one range reference? and filter empty rows.

Bags Purses
Bags Shoulder bags
Bags Crossbody bag
Shoes Sneakers or tennis shoes
Shoes Flats
Shoes Flip flops
Jewelry Necklaces
Jewelry Earrings

This is what i did so far

=ArrayFormula({
 SPLIT(A1&" "&A2:A4," ");
 SPLIT(B1&" "&B2:B4," ");
 SPLIT(C1&" "&C2:C4," ")})    

enter image description here

CodePudding user response:

try:

=INDEX(SORT(QUERY(SPLIT(FLATTEN(A1:C1&"×"&A2:C), "×"), "where Col2 is not null", )))

enter image description here

CodePudding user response:

I solved this problem with this formula:

LAMBDA names
range -->A1:C4
filter_empty --> takes 1 or 0

Set filter_empty 0 to keep empty rows or 1 to filter empty rows.

=ArrayFormula(
 LAMBDA(range,filter_empty,
 QUERY({
 SPLIT(FLATTEN(SPLIT(TRANSPOSE(
 BYCOL(range, LAMBDA(rg, TEXTJOIN("|",1,QUERY(rg,"Limit 1")&"#"&QUERY(rg,"Offset 1"))))), "|")),"#")},
 " Select * Where Col2 <> '"& IF(filter_empty<>0,"","*")&"'"))(A1:C4,0))

enter image description here

Used formulas help
ARRAYFORMULA - LAMBDA - QUERY - SPLIT - FLATTEN - TRANSPOSE - BYCOL - TEXTJOIN - OFFSET - IF

  • Related