HomeGoogle DocsSpreadsheetImport Every Nth Row in Google Sheets Using Query or Filter (Same...

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

Published on

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.

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

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...

More like this

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

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...

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.