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.

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

More like this

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

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.