How to Sort Rows to Bring Blank Cells to the Top in Google Sheets

Published on

There are three methods you can use to sort rows and bring blank cells to the top in Google Sheets: the FILTER command, the QUERY function, and the SORT function with a helper column.

As a side note, there may be other methods, but I will focus on these three in this tutorial.

In this Google Sheets tutorial, you’ll learn how to use these three methods to sort rows to bring blank cells to the top in a column.

Sample Data

To illustrate the methods, let’s use a simple dataset with two columns and a few rows.

Sample Data to Sort Rows and Bring Blank Cells to the Top

Sort Rows to Bring Blank Cells to the Top Using the FILTER Command

Google Sheets’ FILTER command (Data > Create a filter) provides sorting options that we can use for our purpose.

Steps:

  1. Select the dataset (A1:B7), go to the menu Data, and click Create a filter.
  2. Filter column A to bring blank cells to the top:
    • Click the drop-down in cell A1.
    • Click Clear.
    • Select (Blanks).
    • Click OK to isolate the blank cells.
      Select Blank Cells in Data Using 'Create a Filter' Option
  3. Highlight the blank cells (A2:A3) by filling them with a color (e.g., Yellow).
  4. Click the drop-down again, select Select all, and click OK.
  5. Click the drop-down a third time and go to Sort by color > Fill color > Yellow.
Move Blank Cells to the Top Using the FILTER Command

This method effectively sorts rows and brings blank cells to the top in Google Sheets. However, since sorting is applied based on fill color, only the blank cells will move to the top, while the other values will remain in their original order.

Sort Rows to Bring Blank Cells to the Top Using a QUERY Formula

A formula-based approach using the QUERY function allows you to populate the data in a new range with the desired sort order.

In Google Sheets, QUERY includes several clauses, and one of them is ORDER BY. We will use this along with the SELECT clause.

Formula:

Enter the following formula in cell E1:

=QUERY(A1:B7, "SELECT * ORDER BY A ASC", 1)

This formula sorts the dataset while ordering blank cells first in column A.

Sort Rows to Bring Blank Cells to the Top Using QUERY

If you use this formula in a new sheet, include the sheet name with the range. For example:

=QUERY('Sheet1'!A1:B7, "SELECT * ORDER BY A ASC", 1)

Replace ‘Sheet1’ with the actual sheet name, ensuring it is enclosed in single quotes.

Why Not Use SORT or SORTN?

You might wonder why we don’t use SORT or SORTN to sort rows and bring blank cells to the top.

The SORT and SORTN functions place blank cells at the bottom in both ascending and descending order, whereas the QUERY function places blank cells on top in ascending order and at the bottom in descending order.

That said, if you’re unfamiliar with QUERY, you can still use SORT, but you’ll need a helper column.

SORT + Helper Column Approach

This method uses a helper column to sort rows and bring blank cells to the top.

Steps:

  1. Insert the following formula in cell C1 (ensure column C is empty before doing this):
    ={"Helper"; ArrayFormula(A2:A7="")}
    This formula marks blank rows with TRUE and non-blank rows with FALSE.
  2. Use the following SORT formula in cell E2 to order blank cells first:
    =SORT(A2:B7, C2:C7, FALSE, 1, TRUE)

This formula sorts column C in descending order (TRUE values first) while sorting column A in ascending order.

Sort Rows to Bring Blank Cells to the Top Using SORT

Conclusion

These are the three methods to sort rows to bring blank cells to the top in Google Sheets:

  • FILTER menu (manual approach)
  • QUERY formula (dynamic approach)
  • SORT with a helper column (alternative formula approach)

Each method has its use case, so choose the one that best fits your needs.

Thanks for reading! Enjoy working with Google Sheets.

Additional Resources

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.

How to Sort Pie Slices in Google Sheets

To sort pie slices in a pie chart, you need to sort the data...

Filter Items Unique to Groups in Google Sheets

In this tutorial, we'll learn how to filter items unique to groups in Google...

Find Common Items Across Multiple Columns in Google Sheets

This tutorial explains how to find common items across multiple columns in Google Sheets....

Sort Column by Length of Text in Google Sheets

To sort a column by length of text, you can either use the QUERY...

More like this

How to Sort Pie Slices in Google Sheets

To sort pie slices in a pie chart, you need to sort the data...

Filter Items Unique to Groups in Google Sheets

In this tutorial, we'll learn how to filter items unique to groups in Google...

Find Common Items Across Multiple Columns in Google Sheets

This tutorial explains how to find common items across multiple columns in Google Sheets....

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.