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 Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

More like this

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

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.