Search code examples
google-sheetsgoogle-sheets-formulagoogle-sheets-query

Is there a Google Sheets function to squeeze a range into one column?


I wanted to find the built-in function for this to no avail so I had to write it in script:

function squeeze(range) {
  return [].concat(...range).filter(n => n)
}

This JS function flattens the 2D array range and returns it.

Note that it filters out empty cells with uneven columns.


Solution

  • While not officially documented (yet), flatten() also exists as a built-in formula. See here for more info.

    Example

    UPDATE: Since the end of 2020 the function is now documented. See here for more info.