Table.Range returns a new table containing only the rows you ask for, starting at a zero-based offset and keeping a set number of rows. In the Power Query M language it is the cleanest way to drop header junk, grab the top N records, or split a large dataset, and it is written as Table.Range(table, offset, count). You do not need any add-in: Table.Range ships with Power Query in Excel, Power BI Desktop and other tools that use the same engine.
What You'll Need
- Power Query available in your tool (Excel: Data tab > Get & Transform Data; Power BI Desktop: Transform Data). Exact labels can differ slightly by version, device and region.
- A query that already returns a table, or a loaded data source you can point to.
- Basic comfort with the Advanced Editor or the formula bar, though the no-code route works too.
Step-by-Step
- Load your data into Power Query. In Excel, select your range or table and choose Data > From Table/Range. In Power BI Desktop, choose Get Data, pick the source, and open the Power Query Editor.
- Confirm the data is a single, clean table. Table.Range counts rows from the top of whatever table it receives, so if your source has title rows, subtotals or notes above the real header, remove them first. A quick way is to use Home > Remove Rows > Remove Top Rows and set the number you want gone, which does the same job as Table.Range with offset.
- Decide your two numbers before writing anything. The
offsetis how many rows to skip from the top, counted from zero. Thecountis how many rows to keep. So offset 0, count 10 keeps the first ten rows; offset 5, count 10 skips the first five and returns the next ten. - Use the interface first if you are not comfortable with M. On the Home tab, open Keep Rows > Keep Top Rows for offset 0, or Keep Range of Rows if you need to skip some first. That dialog asks for the starting row and the number of rows to keep. Accept it and Power Query writes the step for you.
- Check the generated step in the Applied Steps pane. Click the step and read the formula bar at the top. You will see something like
Table.Range(#"Changed Type", 5, 10). This is where you confirm your numbers landed in the right order: table first, then offset, then count. - To edit manually, open Home > Advanced Editor and add your own line inside the
letblock, for example:KeptRows = Table.Range(Source, 0, 100)
then referenceKeptRowsin the next step and in the finalinstatement. Names are case-sensitive and the final line must name the last step. - Validate the result. Scroll the preview and confirm the row count matches your expectation. Power Query shows the column count and row count in the status bar at the bottom of the preview; a mismatch almost always means the offset was off by the number of header or junk rows.
- Close & Load (Excel) or Close & Apply (Power BI) to write the result back to your workbook or model. Because Table.Range drops rows permanently in that query, keep the original query as a separate, unmodified reference if you think you will need the full data later. Right-click the query and choose Reference or Duplicate before slicing.
Common Mistakes
- Forgetting that offset is zero-based. Asking for offset 1 to "start at row one" actually skips the first data row.
- Swapping offset and count. If you get unexpected row numbers, read the formula bar and check the order: table, offset, count.
- Assuming Table.Range filters. It does not look at values; it slices by position. To keep rows where a column meets a condition, use Table.SelectRows instead.
- Slicing before cleaning. If headers sit in row 3, a Table.Range of the first 10 rows returns headers plus junk, not your data.
- Hardcoding a count that changes. If the source grows, a fixed count silently truncates the data. For "top N" by value, sort first and then keep top rows.
- Typing the table name wrong in the Advanced Editor. M is case-sensitive, and step names containing spaces need
#"quoting, e.g.#"Changed Type".
Tips
- Combine Table.Range with Table.RowCount to make it self-adjusting: offset the junk rows, then keep
Table.RowCount(table) - offsetrows so nothing is cut when the source grows. - Use Table.Range to preview a big source quickly: keep the first few hundred rows while you build the rest of the query, then raise the count before loading.
- Pair it with Table.FirstN and Table.Skip for readable intent. Those functions are just friendly wrappers around the same idea: Skip moves the offset, FirstN sets the count.
- For pagination against an API, Table.Range is not the tool; use the API's own paging parameters.
- Write a comment above the step in the Advanced Editor, such as
// skip 2 title rows and keep 500, so the numbers make sense later.
Troubleshooting
"We cannot convert a value of type ... to type Table". The first argument is not a table. Check that the step name you passed refers to a table step, not a record, list or column.
The step returns fewer rows than expected. Your count is smaller than the remaining rows, or the offset is larger than you thought. Open the preceding step and compare its row count with offset plus count.
Error: "The field 'X' of the record wasn't found" or a name error. The step you reference does not exist, is misspelled, or has a space and needs #"" quoting. Recent steps are listed in the Applied Steps pane; copy the name exactly.
Error: count must be non-negative. M rejects negative counts. If you are calculating Table.RowCount(table) - offset, wrap it so it cannot go below zero, for example by starting from a table you know is longer than the offset.
The data looks right in preview but wrong after refresh. The source row order changed. Table.Range depends on position, so sort the data first with Table.Sort if the result must be stable.
Nothing changes at all. Confirm the last line of the query points to your new step, then click Refresh Preview on the Home tab. If the error persists after that, remove the step and recreate it through Keep Rows so the syntax is generated correctly. If the whole query breaks, use Home > Advanced Editor to paste back an earlier version of the script.
Frequently Asked Questions
Is the Table.Range offset 1-based or 0-based?
Zero-based. Offset 0 is the first row, so offset 0 with count 10 returns rows one to ten.
Does Table.Range filter by values?
No. It slices by position only. Use Table.SelectRows when you want to keep rows where a column matches a condition.
What happens if count is larger than the rows remaining?
Table.Range returns only the rows that exist. It does not error or pad with blanks, which makes large counts safe when you just want "everything after the header".
Can I keep rows from the bottom instead?
Yes, use Table.LastN with a count. Table.Range counts from the top only.
Does Table.Range change the original data?
No. It creates a new table in the query; the source data and the original query steps are untouched, which is why keeping a duplicate query is a sensible safety habit.