The Table.RemoveRows function in Power Query removes rows by their position in a table. You tell it where to start and how many rows to remove, so you can take out rows from the top, the middle, or the bottom.
I’ll go through seven examples below, covering a single row, a block of rows, title rows, the row with the lowest value, two rows in different places, rows between two marker rows, and the first row in each group.
Follow along with the example file
Table.RemoveRows Function Examples.xlsx
Table.RemoveRows Function Syntax
= Table.RemoveRows(table as table, offset as number, optional count as nullable number) as table
- table – the table you want to remove rows from. This is usually the previous step, such as
Source. - offset – the position of the first row to remove. Positions start at 0 and count only the data rows below the column names, so 0 is the first data row, 1 is the second, and so on.
- count (optional) – how many rows to remove, starting at the offset. If you leave it out, only one row is removed.
What it returns – the same table without the removed rows. The column names and all the other rows stay as they are.
I’ve tested the Table.RemoveRows 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.RemoveRows Function
Use this function when you need to:
- Remove a row when you know its position but nothing in the row marks it as one to remove
- Remove a block of rows from the middle of a table
- Remove title or note rows at the top before you promote the headers
- Remove a row whose position you find with a formula, such as the row with the lowest value
- Remove a section that sits between two marker rows
- Remove the first row in each group of a table
Example 1: Remove One Row by Its Position
Let’s start with the simplest use, where you want to remove one row and you know where it is.
Below is an Excel table named Bookings with a weekend art class’s bookings, where the fourth booking (BK-1044) was cancelled over the phone. Nothing in the table records the cancellation, so I want to remove that row by its position and keep the rest.

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.RemoveRows(Source,3)
Result: five bookings, without BK-1044 (Alan Patterson)

Here, the offset is 3 even though BK-1044 is the fourth booking. Table.RemoveRows counts positions from 0, so the first booking is at position 0 and the fourth is at position 3.
An easy way to get the offset is to take the row’s number in the data (not counting the column names) and subtract 1. There’s no count in this formula, so Table.RemoveRows removes just that one row.
Since the offset is a position, it always removes whatever row sits there. If someone sorts the table or adds a booking above BK-1044, an offset of 3 removes a different booking.
So a fixed offset suits a one-off cleanup like this one. If the row needs to go every time the data refreshes and a value in it identifies it (like the Booking ID), filter on that value with the Table.SelectRows function instead.
The offset has to point to a row that exists. This table has six bookings (positions 0 to 5), so an offset of 6 or more gives the error “There weren’t enough elements in the enumeration to complete the operation.”
Example 2: Remove a Block of Rows
When the rows you want to remove sit next to each other, you can remove all of them with one formula by adding a count.
Below is an Excel table named GreenhouseLog with nine temperature and humidity readings, where readings 4, 5, and 6 were taken while the sensor was being recalibrated. I want to remove those three readings.

Open the GreenhouseLog table in the Power Query Editor (Data > From Table/Range), 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.RemoveRows(Source,3,3)
Result: six readings (1 to 3 and 7 to 9)

Here, the first 3 is the offset, so Table.RemoveRows starts at reading 4 (position 3). The second 3 is the count, so it removes reading 4 and the two rows after it.
Important: The count can’t run past the last row. In this table, Table.RemoveRows(Source,7,3) asks for three rows starting at position 7, but only two rows are left from there, so you get the error “There weren’t enough elements in the enumeration to complete the operation.”
Example 3: Remove Title Rows and Then Promote the Headers
Reports exported from other systems often have a title and a blank line above the real headers. With an offset of 0, Table.RemoveRows removes rows from the very top of the table.
Below is an Excel table named ReadingLog with a book club’s reading log, where a title row and a blank row sit above the real headers. I want to remove those two rows and use the header row as the column names.

The table’s own headers are Column1 to Column3, 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:
let
Source = Excel.CurrentWorkbook(){[Name="ReadingLog"]}[Content],
#"Removed Top Rows" = Table.RemoveRows(Source,0,2),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows")
in
#"Promoted Headers"
The Source line reads the table by its name, so if your table has a different name, change ReadingLog to that name. The same goes for the table names in the later examples.
Result: the columns are named Member, Book, and Pages Read, with the five members below them

Here, the Removed Top Rows step removes two rows starting at position 0, which are the title and the blank row. 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.
For rows at the top, Table.Skip(Source,2) gives the same result. Table.RemoveRows is the one to use when the rows you want to remove aren’t at the top, as in the other examples.
Example 4: Remove the Row With the Lowest Value
The offset doesn’t have to be a number you type. You can work it out with another function, which helps when the row you want to remove can be anywhere in the table.
Below is an Excel table named JudgeScores with the scores six judges gave a diver. The competition drops one lowest score, and Judge 2 and Judge 5 both gave a 7, so I want to remove only one of those two rows.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="JudgeScores"]}[Content],
LowestPosition = List.PositionOf(Source[Score],List.Min(Source[Score])),
#"Removed Lowest Score" = Table.RemoveRows(Source,LowestPosition)
in
#"Removed Lowest Score"
Result: five scores, with Judge 2’s 7 removed and Judge 5’s 7 kept

Here, Source[Score] is the list of all the scores, and the List.Min function finds the lowest one (7). The List.PositionOf function then returns the position of the first 7 in that list, which is 1 (Judge 2).
Table.RemoveRows uses that position as the offset and removes just that one row. Judge 5’s 7 stays, which is what you want when only one lowest score should be dropped.
If you used the Table.SelectRows function to keep the scores that aren’t the lowest, it would remove both rows with a 7, because it checks the value in every row.
Follow along with the example file
Table.RemoveRows Function Examples.xlsx
Example 5: Remove Two Rows That Aren’t Next to Each Other
When you need to remove rows from two different places, you can use Table.RemoveRows twice. The order of the two steps matters here.
Below is an Excel table named GuestList with the guests for a dinner, where the second and sixth guests (Heather Adams and Caitlin Martin) have said they can’t come. I want to remove both of them.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="GuestList"]}[Content],
#"Removed Position 5" = Table.RemoveRows(Source,5),
#"Removed Position 1" = Table.RemoveRows(#"Removed Position 5",1)
in
#"Removed Position 1"
Result: five guests, without Heather Adams and Caitlin Martin

Here, the Removed Position 5 step removes Caitlin Martin at position 5. The Removed Position 1 step then removes Heather Adams at position 1, from the table the first step returned.
I removed the lower row first on purpose. Once a row is removed, every row below it moves up one position, while the rows above it stay where they were.
If you removed Heather Adams first, Caitlin Martin would move up to position 4. An offset of 5 in the next step would then remove Joyce Carter instead, and you wouldn’t get an error to warn you.
Example 6: Remove the Rows Between Two Marker Rows
Some exports put a section between two marker rows, like a start line and an end line. You can find both markers and remove everything from one to the other, however many rows are in between.
Below is an Excel table named ExpenseReport with a trip’s expenses, where the expenses still waiting for approval sit between a Pending approval row and an End of pending row. I want to remove that whole section, including the two marker rows.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="ExpenseReport"]}[Content],
StartRow = List.PositionOf(Source[Expense],"Pending approval"),
EndRow = List.PositionOf(Source[Expense],"End of pending"),
#"Removed Pending" = Table.RemoveRows(Source,StartRow,EndRow - StartRow + 1)
in
#"Removed Pending"
Result: five approved expenses (Hotel, Taxi, Team lunch, Parking, and Train)

Here, the StartRow step finds the position of the Pending approval row (3), and the EndRow step finds the position of the End of pending row (6). Table.RemoveRows starts at StartRow and removes EndRow - StartRow + 1 rows, which is 4.
The + 1 is there so the end marker is removed too. If next month’s report has five pending expenses instead of two, the positions change and the formula still removes the whole section.
Important: The marker text has to match exactly, including capitals, or the List.PositionOf function returns -1. A missing start marker then gives the error “The index cannot be negative.”, and a missing end marker gives “The ‘count’ argument is out of range.”
Example 7: Remove the First Row in Each Group
You can also use Table.RemoveRows on smaller tables inside a query, like the rows for each person after you group a table.
Below is an Excel table named TypingTest with three typing-test results for each candidate, listed in the order they were taken. Each candidate’s first result was a practice round, so I want to remove the first row for every candidate.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="TypingTest"]}[Content],
#"Grouped Rows" = Table.Group(Source,{"Candidate"},{{"Results",each Table.RemoveRows(_,0),type table}}),
#"Combined Results" = Table.Combine(#"Grouped Rows"[Results])
in
#"Combined Results"
Result: six rows, with the second and third results for each of the three candidates

Here, the Table.Group function splits the table into one small table per candidate, where the underscore _ stands for each of those small tables. In each one, Table.RemoveRows(_,0) removes the row at position 0, which is that candidate’s practice round.
The Table.Combine function then stacks the small tables in the Results column back into one table, with the same columns as the original.
This removes whichever row comes first for each candidate, so it works because the results are listed in the order they were taken. A candidate with only one result would drop out of the table completely, since removing that row leaves nothing.
Other Excel Articles You May Also Like:
- Table.Skip – Use Table.Skip in Power Query M to remove rows from the top of a table.
- Table.RemoveColumns – Use Table.RemoveColumns in Power Query M to delete columns.
- List.Skip – Use List.Skip in Power Query M to skip items at the start of a list.
- Table.FirstN – Use Table.FirstN in Power Query M to keep the first rows of a table.
- Table.Distinct – Use Table.Distinct in Power Query M to remove duplicate rows.
- Table.ReverseRows – Use Table.ReverseRows in Power Query M to flip row order.
- Table.RowCount – Use Table.RowCount in Power Query M to count table rows.
- Table.SelectColumns – Use Table.SelectColumns in Power Query M to keep only the columns you need.