INFO

This page was originally generated from official documentation.

Flattens all the values from one or more ranges into a single column.

Sample Usage

=FLATTEN(A1:B2)
=FLATTEN("top", A1:B2, "middle", B3:B4, "bottom")

Syntax

=FLATTEN(range1, [range2, …])
PartDescription
range1The first range to flatten.
range2[optional] repeatable Additional ranges to flatten.

Notes

  • Values are ordered by argument, then row, then column. So, the entire first row of an input is added before the second row (also known as row-major order).
  • Empty values are not skipped; the FILTER function can be used to remove those.

Examples

Make a copy

Flatten will append arguments in the order they are included in the formula. Arguments need not be range references.

ABCD
112Formula in D1: =FLATTEN(A1:B2, “sample middle”, B3:B4)1
2342
353
464
5sample middle
65
76

A more complex example, using the CONCAT (&) operator and SPLIT to do a simple cross join or Cartesian product on two lists.

ABCDE
1A1**Formula in D1: =ArrayFormula(SPLIT(FLATTEN(A1:A3 & "" & TRANSPOSE(B1:B2)), ""))**A1
2B2A2
3CB1
4B2
5C1
6C2

History

The FLATTEN function was originally undocumented and was first discovered on March 15, 2020 by a user named Andy on the Google Docs Editors Help Community forum. It has since been officially recognized, although it has been mostly deprecated by TOCOL.

Matt King’s sheet, which was escalated to Google, can be found here.