List.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 List.Skip function in Power Query removes items from the start of a list and gives you the rest. You can skip one item, a set number of items, or keep skipping while the items meet a condition.

The examples below cover all three, including how to skip blank cells at the top of a column and how to work with every column of a table except the first.

Follow along with the example file

List.Skip Function Examples.xlsx

Download

List.Skip Function Syntax

List.Skip(list as list, optional countOrCondition as any) as list
  • list – the list you want to skip items from. It can be a list you type in curly brackets, like {1,2,3}, or a column from a table that your query has loaded (Example 3 shows how).
  • countOrCondition (optional) – how many items to skip, or a condition. A number, like 3, skips up to that many items from the start. A condition, like each _=0 (is the item 0?), skips items from the start while they meet it. If you leave it out, List.Skip skips just the first item.

What it returns: A list with the remaining items, in their original order. If you skip as many items as the list has (or more), you get an empty list.

The List.Skip function is part of the core Power Query M library, so it works wherever Power Query does, including Excel for Microsoft 365, 2024, 2021, 2019, and 2016 (on Windows for 2019 and 2016), and Power BI.

When to Use the List.Skip Function

Use this function when you need to:

  • Drop a header or label that ended up as the first item of a list
  • Ignore the first few values in a column, like test or warm-up readings
  • Skip leading zeros or blanks until the real data starts
  • Get every item after a marker, like a header line in an imported report
  • Work with every column of a table except the first one

List.Skip is the opposite of the List.FirstN function, which keeps the first items instead of removing them. To remove whole rows from the top of a table, use the Table.Skip function instead.

Example 1: Skip the First Item of a List

Let’s start with the simplest case. Suppose you have a list of regions, but the first item is the label “Region”, and you only want the region names.

In Excel, go to Data > Get Data > From Other Sources > Blank Query. In the Power Query Editor that opens, type this formula in the formula bar:

= List.Skip({"Region","North","South","East","West"})

Result: North, South, East, West

List.Skip with no count removes the Region label: North, South, East, West

Here, there’s no second argument, so List.Skip removes just the first item. That’s why the label is gone and the four regions are left.

Examples 1 and 2 type their list right into the query, so they don’t need a table on a worksheet. In the example file, you can open them from Data > Queries & Connections.

Example 2: Skip the First Few Items

Now let’s skip more than one item. Suppose you have a list of the 12 months, and you only want the last quarter, October to December.

Create a new blank query and use this formula:

= List.Skip({"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"},9)

Result: Oct, Nov, Dec

Skipping the first 9 months leaves Oct, Nov, Dec

Here, the second argument is 9, so List.Skip removes the first nine months (January to September) and returns the three that are left.

If the count is bigger than the list, say 15 for this list, you get an empty list and no error. That’s different from List.FirstN, which returns the whole list when you ask for too many items.

A count of 0 skips nothing, so you get the whole list back. A negative count, like -1, gives the error “The ‘countOrCondition’ argument is out of range.”

Example 3: Skip Warm-Up Readings in a Column

Now let’s use a column from a table. Below is an oven temperature log (in °C) taken every minute, and I want the readings without the first three, while the oven was still warming up.

OvenReadings table with the first three warm-up readings

The readings are in an Excel Table named OvenReadings. The code below reads it by that name, so for your own data, change “OvenReadings” to the name of your table.

Create a new blank query, open the Advanced Editor (Home > Advanced Editor), and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="OvenReadings"]}[Content],
SteadyReadings = List.Skip(Source[Temperature],3)
in
SteadyReadings

Result: 180, 182, 179, 181, 180

Readings from minute 4 onward: 180, 182, 179, 181, 180

Here, Source[Temperature] gives the Temperature column as a list, from minute 1 to minute 8. List.Skip removes the first 3 readings (92, 141, and 168), so you’re left with the readings from minute 4 onward.

You can wrap this in another list function to use the result. For example, List.Average(List.Skip(Source[Temperature],3)) gives the average temperature without the warm-up readings.

Example 4: Skip Leading Zeros

Now let’s use a condition instead of a number. Below is a production log with the units made each hour, and I want the units from the first hour the line actually produced something, since it started late.

HourlyOutput table with zeros in Hours 1 to 3 and Hour 6

The data is in an Excel Table named HourlyOutput (use your own table’s name in the code). Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="HourlyOutput"]}[Content],
ProductionRun = List.Skip(Source[Units],each _=0)
in
ProductionRun

Result: 46, 52, 0, 49, 51

List.Skip removes only the leading zeros: 46, 52, 0, 49, 51

Here, each _=0 is the condition, and the underscore (_) stands for each value in the list. List.Skip removes values from the top while they’re 0, and stops at the first value that isn’t (46 in Hour 4).

Everything after that point stays, including the 0 in Hour 6. That’s what you want here, because Hour 6 was a real hour with no output, not part of the late start.

Compare that with the List.Select function, which checks every item in the list, not just the ones at the start. Create another blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="HourlyOutput"]}[Content],
NonZeroUnits = List.Select(Source[Units],each _<>0)
in
NonZeroUnits

Result: 46, 52, 49, 51

List.Select removes every zero: 46, 52, 49, 51

Here, List.Select keeps only the values that aren’t 0, so the Hour 6 zero is gone too. If you’re working out the average output per hour once the line started, that hour should count, so List.Skip is the right choice here.

So use List.Skip when only the items at the start need to go, and List.Select when a matching item should be removed wherever it is.

Follow along with the example file

List.Skip Function Examples.xlsx

Download

Example 5: Skip Leading Blanks

This one comes up when a column starts with empty cells. Below is the monthly sales of a new store that opened in April, so January to March are blank, and I want the sales from the opening month onward.

NewStoreSales table with blank sales for Jan to Mar

The sales are in an Excel Table named NewStoreSales (use your own table’s name in the code). Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="NewStoreSales"]}[Content],
SalesSinceOpening = List.Skip(Source[Sales],each _=null)
in
SalesSinceOpening

Result: 8200, 9150, 10400, 9800, 11250

Sales from April onward: 8200, 9150, 10400, 9800, 11250

Here, a blank cell comes into Power Query as null. The condition each _=null skips values while they’re blank, so List.Skip removes January to March and stops at April.

If a month later in the list were blank, it would stay in the result as null, because List.Skip only looks at the start. Also, a cell with just a space in it isn’t null, so List.Skip would stop there.

Example 6: Skip Everything Up to a Marker

Sometimes the number of items to skip changes each time. Below is an order report pasted into one column, with a few report lines and an “Order ID” header above the actual order IDs, and I want only the order IDs.

ReportLines table with report lines and an Order ID header above the order IDs

The lines are in an Excel Table named ReportLines (use your own table’s name in the code). Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="ReportLines"]}[Content],
OrderIDs = List.Skip(Source[Line],List.PositionOf(Source[Line],"Order ID")+1)
in
OrderIDs

Result: ORD-5021, ORD-5022, ORD-5025, ORD-5030

Only the order IDs below the Order ID header

Here, the List.PositionOf function finds “Order ID” in the list. Positions in Power Query start at 0, so it returns 3, and adding 1 gives 4, the number of lines up to and including the header.

List.Skip then skips those 4 lines. If next week’s report has more lines above the header, the count changes on its own, so the query still returns only the order IDs.

If “Order ID” isn’t in the list, List.PositionOf returns -1, so the count becomes 0 and you get the whole list back. Check for that if your reports might be missing the header.

Example 7: Get Every Column Except the First

List.Skip also works on lists of column names. Below is a table of units sold per product by month, and I want to set every month column to the number type, without listing the months one by one.

ProductUnits table with Product and four month columns

The data is in an Excel Table named ProductUnits (use your own table’s name in the code). Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="ProductUnits"]}[Content],
MonthColumns = List.Skip(Table.ColumnNames(Source)),
ChangedType = Table.TransformColumnTypes(Source,List.Transform(MonthColumns,each {_,type number}))
in
ChangedType

Result: The ProductUnits table, with the Jan, Feb, Mar, and Apr columns set to the number type

Month columns set to the number type, Product unchanged

Here, the Table.ColumnNames function returns the column names as a list, from Product to Apr. List.Skip removes the first name (Product), so MonthColumns holds only the month names.

The List.Transform function turns each month name into a pair like {"Jan",type number}, which is the format the Table.TransformColumnTypes function needs. If you add a May column later, the query picks it up without any change.

Example 8: Add a Row Total Without the First Column

In this last example, List.Skip works on the values in each row. Below is a table of quarterly expenses for each team, and I want a Total column that adds up Q1 to Q4.

TeamExpenses table with Q1 to Q4 expenses per team

The expenses are in an Excel Table named TeamExpenses (use your own table’s name in the code). Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="TeamExpenses"]}[Content],
AddedTotal = Table.AddColumn(Source,"Total",each List.Sum(List.Skip(Record.FieldValues(_))),type number)
in
AddedTotal

Result: A new Total column with 17800, 12150, 25200, and 8300

New Total column: 17800, 12150, 25200, 8300

Here, the Table.AddColumn function adds the Total column and works out its value one row at a time. Inside it, the underscore (_) stands for the current row, with all its columns.

The Record.FieldValues function returns that row’s values as a list, like {"Marketing",4200,3900,4600,5100}. List.Skip removes the first value (the team name), and the List.Sum function adds up the four amounts.

The type number at the end sets the new Total column’s data type to number, so you don’t need a separate Changed Type step for it.

Because the code doesn’t name the quarter columns, it works for any number of them. Just keep the team name as the first column, since List.Skip removes whatever comes first.

Other Excel Articles You May Also Like:

  • Table.RemoveRows – Use Table.RemoveRows in Power Query M to delete rows by position.
  • Table.FirstN – Use Table.FirstN in Power Query M to keep the first rows of a table.
  • Table.RemoveColumns – Use Table.RemoveColumns in Power Query M to delete columns.
  • List.First – Use List.First in Power Query M to get the first item in a list.
  • List.IsEmpty – Use List.IsEmpty in Power Query M to check whether a list has values or is empty.
  • Table.SelectColumns – Use Table.SelectColumns in Power Query M to keep only the columns you need.
  • List.Difference – Use List.Difference in Power Query M to find items in one list but not another.
  • List.NonNullCount – Use List.NonNullCount in Power Query M to count the filled, non-null values in a list.

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.