Consolidating matrix data, questionnaire responses, or product catalogs often requires reshaping scattered multi-row tables into a continuous horizontal sequence. Previously in Google Sheets, transforming a two-dimensional grid into a single row required daisy-chaining TRANSPOSE, FLATTEN, or array concatenation formulas. The native TOROW dynamic array function streamlines this process, enabling users to flatten any 2D dataset into a clean, horizontal row using a single calculation.
Understanding the Syntax of TOROW
The TOROW function accepts three arguments, matching the capabilities of its vertical counterpart TOCOL:
=TOROW(array, [ignore], [scan_by_column])
Argument definitions:
array: The two-dimensional range, array, or formula calculation to reshape into a single horizontal vector.[ignore]: A numeric parameter controlling which values to omit:0(Default): Retain all cells, including empty cells and error values.1: Ignore blank cells.2: Ignore error values.3: Ignore both blank cells and error values.
[scan_by_column]: Determines reading direction:FALSE(Default): Scans by row (left-to-right, then down).TRUE: Scans by column (top-to-bottom, then right).
Basic Example: Flattening a Weekly Schedule into a Single Row
Suppose you have staff shift schedules laid out in cells A2:E5 representing shifts across Monday through Friday. To flatten all staff names into a continuous horizontal timeline in row 8 while omitting empty shifts:
=TOROW(A2:E5, 1)
Google Sheets immediately spills the entries horizontally across row 8, automatically skipping unscheduled blank cells and leaving no gaps in the timeline.
Scanning by Row vs Scanning by Column
Choosing the correct scanning direction ensures that chronological order or thematic grouping remains intact:
| Scanning Mode | Formula Example | Order of Extraction |
|---|---|---|
| Scan by Row (Default) | =TOROW(A1:C2, 0, FALSE) |
A1, B1, C1, A2, B2, C2 |
| Scan by Column | =TOROW(A1:C2, 0, TRUE) |
A1, A2, B1, B2, C1, C2 |
Pairing TOROW with UNIQUE and TEXTJOIN
Combining TOROW with other modern dynamic array functions unlocks powerful data wrangling workflows:
1. Unique Horizontal Tags
Extract unique categories from a multi-row product matrix without blanks:
=UNIQUE(TOROW(A2:D20, 1), TRUE)
Note: Passing TRUE as the second argument to UNIQUE instructs it to compare unique values by column across horizontal vectors.
2. Creating Delimited Summary Headers
Combine flattened horizontal rows directly into delimited strings or report titles:
=TEXTJOIN(" | ", TRUE, TOROW(A2:D5, 3))
TOROW vs TOCOL Comparison
| Function | Spill Direction | Best Suited For |
|---|---|---|
TOROW |
Horizontal (1 × N) | Timeline headers, horizontal charts, CSV export preparation |
TOCOL |
Vertical (M × 1) | Database normalization, lookup ranges, pivot table inputs |
By mastering the TOROW function in Google Sheets, spreadsheet builders can easily reformat tabular grids into clean, horizontal datasets with minimal formula overhead.