Table.Skip Function in Power Query M

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

The Table.Skip function in Power Query removes rows from the top of a table. You can tell it how many rows to remove, or give it a condition, and it keeps removing rows until it reaches one that doesn’t match.

I’ll go through eight examples below, covering test rows, title rows above the headers, a header row that moves, blank rows, and skipping rows in several tables before combining them.

Follow along with the example file

Table.Skip Function Examples.xlsx

Download

Table.Skip Function Syntax

= Table.Skip(table as table, optional countOrCondition as any) as table
  • table – the table you want to remove rows from. This is usually the previous step, such as Source.
  • countOrCondition (optional) – the number of rows to remove from the top, or a condition. With a condition, rows are removed from the top as long as they meet it, and the function stops at the first row that doesn’t. If you leave it out, only the first row is removed.

What it returns – the same table without the rows that were skipped. The column names and the remaining rows stay as they are.

I’ve tested the Table.Skip function in Power Query in Excel for Microsoft 365. It’s also part of the Power Query M language that Power BI uses.

When to Use the Table.Skip Function

Use this function when you need to:

  • Remove a fixed number of rows from the top of a table
  • Get rid of title rows, notes, or blank rows that sit above the real header row
  • Remove the top rows when their number changes from one file to the next
  • Remove the leading rows that meet a condition, while keeping later rows that meet it
  • Clean up the top rows of several tables before you combine them

Example 1: Skip a Fixed Number of Rows

Let’s start with the simplest use, where you know exactly how many rows to remove.

Below is an Excel table named FormResponses with the responses to a feedback form, where the first three rows are test entries made while the form was being set up. I want to remove those three rows and keep the real responses.

Form responses with three test entries at the top

To follow along, select any cell in the table and go to Data > From Table/Range to open it in the Power Query Editor. If Power Query adds a Changed Type step, use #"Changed Type" in place of Source in the formulas below.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.Skip(Source,3)

Result: the five real responses, from Margaret Parker to Joanna Carter

First three test rows skipped, five real responses left

Here, the 3 tells Table.Skip to remove the first three rows of the table. The column names are not counted as a row, so they stay as they are.

You can do the same thing from the ribbon. In the Power Query Editor, go to Home > Remove Rows > Remove Top Rows, and enter 3.

The Table.FirstN function works the other way around. It keeps the first rows and drops the rest, while Table.Skip drops the first rows and keeps the rest.

Example 2: Leave Out the Count to Skip Just One Row

If you only want to remove one row, you don’t need to give a count at all.

Below is an Excel table named Shipments with the weight, length, and cost of each package, where the first row only holds the units (kg, cm, and USD). I want to remove that units row so only the packages are left.

Shipments table with a units row under the headers

Select any cell in the Shipments table and go to Data > From Table/Range to open it in the Power Query Editor, as in Example 1. Then add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.Skip(Source)

Result: the five packages, from PKG-201 to PKG-205, without the units row

Units row skipped with the count left out

Here, there’s no second argument, so Table.Skip removes only the first row. Table.Skip(Source) gives the same result as Table.Skip(Source,1).

Remove a units row like this before you set the column data types. If you change the Weight column to a number type while the row is still there, the kg cell can’t be converted to a number and shows an Error.

Example 3: Skip Title Rows and Then Promote the Headers

Reports exported from other systems often have a title or a note line above the actual headers. Table.Skip removes those lines so the header row ends up at the top.

Below is an Excel table named AttendanceReport with a class attendance report, where a report title and a class line sit above the real headers (Student, Days Present, Days Absent, and Late Arrivals). I want to remove the two title rows and use the header row as the column names.

Attendance report with two title rows above the header row

The table’s own headers are Column1 to Column4, which is what you’d see after importing a report that Power Query didn’t treat as having headers.

Create a blank query (Data > Get Data > From Other Sources > Blank Query). In the Power Query Editor, open the Advanced Editor (Home > Advanced Editor) and use this code.

The Source line reads the table by its name, so if your table has a different name, change AttendanceReport to that name. The same goes for the table names in the later examples.

let
Source = Excel.CurrentWorkbook(){[Name="AttendanceReport"]}[Content],
#"Removed Top Rows" = Table.Skip(Source,2),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows")
in
#"Promoted Headers"

Result: the columns are named Student, Days Present, Days Absent, and Late Arrivals, with the five students below them

Two title rows skipped and the header row promoted

Here, the Removed Top Rows step uses Table.Skip to remove the first two rows. That leaves the header row at the top, and the Promoted Headers step uses the Table.PromoteHeaders function to turn it into the column names.

The order matters. If you promote the headers first, the report title becomes a column name, and the real header row stays in the data.

Example 4: Skip Rows Until You Reach the Header Row

A fixed count, like the 2 in Example 3, works only as long as the number of title rows never changes. Some exports add a different number of note lines each time, so a fixed count would skip too few or too many rows.

Below is an Excel table named OrderExport with an online store’s order export, where three note lines sit above the real headers (Order ID, Customer, Item, and Qty). I want to remove the note lines without hard-coding how many there are.

Order export with three note lines above the header row

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="OrderExport"]}[Content],
#"Removed Top Rows" = Table.Skip(Source,each [Column1] <> "Order ID"),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows")
in
#"Promoted Headers"

Result: the columns are named Order ID, Customer, Item, and Qty, with the five orders below them

Rows skipped until Order ID and the header row promoted

Here, instead of a number, I gave Table.Skip a condition. The each keyword checks the condition for one row at a time, and [Column1] is that row’s value in Column1.

Table.Skip keeps removing rows as long as Column1 is not “Order ID”, and it stops at the first row where it is, which is the header row. So whether the export has one note line or five, the header row ends up at the top.

Important: The match is exact and case-sensitive, so if the header ever changes (say to “Order No”), no row has Order ID in Column1. Every row then meets the condition, Table.Skip removes all of them, and you get an empty table instead of an error.

Follow along with the example file

Table.Skip Function Examples.xlsx

Download

Example 5: Skip Note Rows and Blank Rows Without Knowing the Header

The condition in Example 4 needs the exact header text. If you don’t know it, you can check for something else that’s true only for the junk rows, like a column that’s empty in all of them.

Below is an Excel table named ExpenseClaims with an expense claims export, where a title, a blank row, and a note sit above the real headers (Claim ID, Employee, Category, and Amount). I want to remove everything above the header row.

Expense claims export with a title, a blank row and a note above the headers

The title and the note only fill the first column, and the blank row has nothing at all. So in all three rows, the fourth column is empty.

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="ExpenseClaims"]}[Content],
#"Removed Top Rows" = Table.Skip(Source,each [Column4] = null),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows")
in
#"Promoted Headers"

Result: the columns are named Claim ID, Employee, Category, and Amount, with the five claims below them

Rows with an empty Column4 skipped and the header row promoted

Here, an empty cell comes into Power Query as null, so [Column4] = null is true for the title, the blank row, and the note. Table.Skip removes those three rows and stops at the header row, because its fourth column has the text Amount.

This works as long as the column you check is filled in the header row. Pick a column that’s empty in the note rows but always has a header.

Example 6: Skip Only the Leading Rows That Meet a Condition

A condition in Table.Skip removes matching rows only at the top of the table. Once it hits a row that doesn’t match, it stops checking, even if later rows match too.

Below is an Excel table named LaunchSales with the weekly units sold of a new product. Weeks 1 to 3 show 0 because the product hadn’t launched yet, and week 7 shows 0 because it was out of stock that week.

I want to remove the pre-launch weeks but keep week 7.

Weekly launch sales with zero units in weeks 1 to 3 and week 7

Select any cell in the LaunchSales table and go to Data > From Table/Range to open it in the Power Query Editor, as in Example 1. Then add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.Skip(Source,each [Units Sold] = 0)

Result: weeks 4 to 10 (seven rows), including week 7 with 0 units sold

Leading zero weeks skipped, week 7 kept

Here, Table.Skip removed weeks 1, 2, and 3, and stopped at week 4 because it has 120 units. Week 7 also has 0 units, but Table.Skip never looked at it, since it had already stopped.

Compare that with the Table.SelectRows function, which checks every row in the table. To try it, open the LaunchSales table in a new query (Data > From Table/Range again) and add a step with this formula:

= Table.SelectRows(Source,each [Units Sold] <> 0)

Result: six rows, with weeks 1 to 3 and week 7 all removed

Table.SelectRows removes every zero week, including week 7

Here, the Table.SelectRows function removed every row with 0 units, so week 7 is gone too. If you’re working out the average weekly sales since launch, that out-of-stock week should count, so Table.Skip is the right choice here.

So use Table.Skip when only the rows at the top need to go, and the Table.SelectRows function when a matching row should be removed wherever it is.

Example 7: Skip a Number of Rows Stored in a Cell

You don’t have to type the count into the formula. It can come from a cell, so someone who doesn’t use Power Query can change it without opening the query.

Below is an Excel table named SurveyExport with a survey export, where four lines of survey details sit above the real headers (Respondent, Department, and Score).

Survey export with four detail lines above the header row

And on the Example 7 – Settings sheet, a small table named SkipSettings has the number of rows to skip (4) in its Rows to Skip column. I want the query to read that number and skip that many rows.

SkipSettings table with 4 in the Rows to Skip column

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="SurveyExport"]}[Content],
RowsToSkip = Excel.CurrentWorkbook(){[Name="SkipSettings"]}[Content]{0}[Rows to Skip],
#"Removed Top Rows" = Table.Skip(Source,RowsToSkip),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows")
in
#"Promoted Headers"

Result: the columns are named Respondent, Department, and Score, with the five responses below them

Four rows skipped using the count from the settings table

Here, the RowsToSkip step reads the SkipSettings table, and {0}[Rows to Skip] picks the value in its first row under the Rows to Skip column, which is 4. Table.Skip then uses that number as the count.

To change the count later, type a new number in the Rows to Skip cell and refresh the query (Data > Refresh All).

If someone enters a number larger than the number of rows, Table.Skip doesn’t give an error. It returns an empty table with the same column names.

A negative number, on the other hand, gives the error “We expected a CountOrCondition value.” The count must be a whole number of 0 or more.

Also keep the cell filled. If it’s blank, RowsToSkip becomes null, and Table.Skip treats that like a missing count and removes only the first row.

Example 8: Skip the Title Rows in Several Tables Before Combining Them

When you combine tables that each have their own title rows, you need to clean up each table before stacking them. Otherwise the title rows of the second table end up in the middle of the data.

Below is an Excel table named Week1Hours with the first week’s timesheet, where two title rows sit above the real headers (Employee, Project, and Hours).

Week 1 timesheet with two title rows above the header row

And below is a second table named Week2Hours with the same layout for week 2. I want to stack both weeks into one table with proper headers.

Week 2 timesheet with the same layout

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="Week1Hours"]}[Content],
Week2 = Excel.CurrentWorkbook(){[Name="Week2Hours"]}[Content],
#"Appended Tables" = Table.Combine(
List.Transform({Source,Week2},each Table.PromoteHeaders(Table.Skip(_,2))))
in
#"Appended Tables"

Result: six rows (three from each week) under the headers Employee, Project, and Hours

Both weeks cleaned and combined into six rows

Here, the List.Transform function runs the same cleanup on each table in the list, where the underscore _ stands for each table. For each one, Table.Skip removes the two title rows and the Table.PromoteHeaders function turns the header row into the column names.

Each table now has the same column names, so the Table.Combine function stacks them into one table, with the header row showing up only once.

You’d use the same pattern when you combine CSV files from a folder, where every file has the same title rows at the top.

Other Excel Articles You May Also Like:

All Power Query Functions

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.