Import Every Nth Row in Google Sheets Using Query or Filter (Same File)

To import or extract every nth row from one sheet to another sheet in the same file in Google Sheets, we can use the Query or Filter functions.

Some of you may already know the combination of IF, MOD, and ROW to extract the values from every nth row.

I have already published the same here – How to Copy Every Nth Cell in a Column in Google Sheets.

It has (the above combo formula) one issue! The output will have lots of blank rows as the formula simply extracts value from every nth row and place it in another column in the same row.

For example, see the values in A3:B and my formula in cell C3 in the same sheet which returns values from every 5th row (for this kind of formula explanation, please refer to the above-linked tutorial).

=ArrayFormula(
     if(
        mod(row(A3:A)-row(A3),5)=0,
        A3:B,
     )
)
Blank cells between the result cells

Points to Note

  • If you want to extract value from only column B, then just change A3:B to B3:B. If the values are from A1:B, not A3:B, then change all the numbers 3 in the formula to 1.
  • The number 5 is the ‘n’ in the above formula. Feel free to change that.
  • The formula is on the same sheet. If the above data is in ’employee’ sheet and wants to import the values to the ‘summary’ sheet in the same file, use the below formula.
=ArrayFormula(
     if(mod(row(employee!A3:A)-row(employee!A3),5)=0,
        employee!A3:B,
     )
)

See the blank rows between the extracted values. How to omit that?

We can use the Filter or Query function for that. Let’s see how to import every nth row in Google Sheets without ‘unwanted’ blank rows. If the nth row is blank, that will be included in the result.

Filter to Import Every Nth Row in Google Sheets

The Filter formula is almost the same as the above combo formula. Here instead of the IF logical test, we can use Filter.

Syntax:

FILTER(
     range,
     condition1
)

I hope the following formula is self explanative.

=filter(
     employee!A3:B,
     mod(row(employee!A3:A)-row(employee!A3),5)=0
)

Here also the ‘n’ is set to 5. The data/range is in A3:B in the ’employee’ sheet and the formula is in another sheet in the same file.

To make you understand the difference with IF formula, I am inserting this formula in the same source data sheet, i.e. ’employee’.

Filter to Import Every Nth Row in Google Sheets Using Query or Filter

Here is one more formula which may be new to many Sheet’s users.

Query to Import Every Nth Row in Google Sheets

Did you ever use or heard about the SKIPPING clause in Google Sheets Query? If not, you can go through my post – How to Move Each Set of Rows to Columns in Google Sheets.

Using the SKIPPING clause it’s quite easy to import/extract/filter every nth row in Google Sheets.

=query(employee!A3:B,"Select * Skipping 5")

The SKIPPING clause skips a certain number of elements from the result based on the count parameter. Here the count parameter is 5 which is our ‘n’.

The above Query returns columns A and B similar to the filter example above.

If you want only a particular column(s) after skipping rows, you can specify that in the SELECT clause like Select A instead of Select *. Please check my Query clause order for more info.

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.

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

Extract Items Under a Category from the Same Column in Excel

In Excel, you can use a combination of the XLOOKUP and DROP functions to...

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

Time Sequences in Excel by Minute, Hour, or Second Increments

Creating time sequences, whether by hour, minute, or second increments in Excel, can be...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

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.