HomeGoogle DocsSpreadsheetTOROW Function in Google Sheets (How To)

TOROW Function in Google Sheets (How To)

Published on

This tutorial explains how to use the TOROW function in Google Sheets. Also, we can discuss one real-life use of this function.

The purpose of this newly introduced (2023) function in Sheets is to transform a range of cells into a single row.

It avoids using FLATTEN, TRANSPOSE, and FILTER combinations, a workaround solution to transform a table or array into a single row.

The combination function won’t be the cup of tea for many new Sheets users.

They may prefer standalone functions for data manipulation.

In that context, this new function will be a relief for many Sheets enthusiasts.

TOROW Function Syntax and Arguments

Syntax: TOROW(array_or_range, [ignore], [scan_by_column])

Arguments:

array_or_range — The array or cell range to return as a row.

ignore — Whether to ignore blanks (1), errors (2), or both (3). By default (0), no values are ignored. Specify 0, 1, 2, or 3 accordingly.

scan_by_column — TRUE (by column) or FALSE (by row [default]).

Here are a few examples of using the TOROW function in Google Sheets.

TOROW Function Examples in Google Sheets

Please see the values in the range B2:D6, which I’ve generated using the following SEQUENCE formula in B2: =sequence(5,3)

TOROW Function - Examples

In G2, I’ve used a TOROW formula to scan these values by column.

=torow(B2:D6,0,true)

The G5 formula scans the values by row.

=torow(B2:D6,0,false)

Understand the difference, and you won’t falter in using the TOROW function in Google Sheets.

In both formulas, the ignore parameter is set to 0, which means returning the values as it is.

Alternative Solutions

You can ignore the below formulas. I just put it to show you how complex things were earlier.

G2:

=transpose(flatten(transpose(B2:D6)))

G5:

transpose(flatten(B2:D6))

One of the issues with these alternatives to the TOROW function is you may additionally require to use FILTER and IFERROR to ignore blanks, errors, or both.

TOROW Real-life Use: Inserting Blank Columns between Data

Sometimes we can better manipulate values in a range of cells in Sheets when it is in a single row or column.

We can use the TOROW function in Google Sheets for transforming the range of cells into a row.

After manipulating the values, with the help of WRAPROWS, we can transform the single rows of values back into the range of cells.

In the following examples, you can learn how to insert blank columns between data using a combination of TOROW and WRAPROWS functions in Google Sheets.

Similar: How to Insert Blank Columns in Google Sheets Query.

Inserting Blank Columns between Data

The following Google Sheets formula in cell D11 inserts blank columns between the source data in D3:K7.

=let(
     data,
     D3:K7,
     iferror(
          wraprows(
               torow(
                   {torow(data,0,false);
                    index(torow(data/0,0,false))
                   },
                   0,true
               ),
               columns(data)*2
          )
     )
)

How does the above formula be able to insert blank columns between data?

There are four key steps.

1. First, we should flatten the data into a row by scanning the values by row. So the scan_by_column is set to FALSE.

torow({torow(data,0,false)

2. The next step is to generate error cells matching the number of cells in the data range.

index(torow(data/0,0,false))

Then create an array in the following syntax: {step#1;step#2}

3. Use another TOROW to flatten this ‘new’ array into a row, but this time scan by column. So the scan_by_column is set to TRUE.

TOROW({step#1;step#2},0,true)

It will place one error value after every value.

4. Finally, the WRAPROWS creates an array.

Syntax: WRAPROWS(range, wrap_count, [pad_with])

Please note that the wrap_count is the number of columns in the data * 2.

This way, we can insert blank columns between data using WRAPROWS and TOROW functions in Google Sheets.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Running Total By Month in Excel

This tutorial demonstrates how to calculate the running total by month in a range...

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

Get Top N Values Using Excel’s FILTER Function

When using the FILTER function in Excel to extract the top N values, it's...

More like this

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.