Skip to content

Instantly share code, notes, and snippets.

@andrewcharlesmoss
Created March 17, 2022 17:38
Show Gist options
  • Save andrewcharlesmoss/914f7830bcc523d799035032b72b0635 to your computer and use it in GitHub Desktop.
Save andrewcharlesmoss/914f7830bcc523d799035032b72b0635 to your computer and use it in GitHub Desktop.
FLATTEN function to flatten all the values from one or more ranges into a single column
FLATTEN =
LAMBDA(array,
LET(
rows,ROWS(array),
columns,COLUMNS(array),
sequence,SEQUENCE(rows*columns),
quotient,QUOTIENT(sequence-1,columns)+1,
mod,MOD(sequence-1,columns)+1,
INDEX(IF(array="","",array),quotient,mod)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment