Search code examples
google-sheetsgoogle-sheets-formula

Column Stacking & Inventory Numbering In Google Sheets


Long time lurker. I can't quite get this right. I'm attempting to Repeat Column 1 x many times based on multiple columns of integers in Google Sheets.

This is the formula I am using.

=ArrayFormula(QUERY(FLATTEN(SPLIT(REPT(text(A1:A4,"0")&""&"|",TRANSPOSE(SPLIT(ARRAYFORMULA(CONCATENATE(TRANSPOSE(FILTER(B1:D4,B1:B4>0)&"-"))),"-"))),"|",1,1)),"Select * WHERE Col1 Is Not Null"))

It repeats column A B1:B4 times but does not continue through C&D.

Google Sheets Sample

Link To Google Sheet Here

Any guidance? I've got to be close...


Solution

  • One more approach:

    =tocol(map(tocol(index(if(B:D,A:A,)),1,1),tocol(B:D,1,1),lambda(Λ,Σ,wraprows(Λ,Σ,Λ))),3)
    

    enter image description here