To keep the bottom rows in Power Query, go to the Home tab, select Keep Rows, and choose Keep Bottom Rows, then enter the number of rows you wish to retain. This process removes all rows from the top of your dataset, leaving only the most recent or final entries based on the current sort order of your table. This is essential for analysts who need to isolate the latest transactions, the final summaries of a report, or the most recent date-stamped entries in a large data export without manually deleting thousands of rows.

What You'll Need

  • Microsoft Excel or Power BI Desktop installed on your machine.
  • A data source (CSV, Excel workbook, SQL database, or web page) already loaded into the Power Query Editor.
  • A clear understanding of how many rows you need to keep, or a way to determine that number based on your data structure.

Step-by-Step

  1. Open the Power Query Editor: In Excel, go to the Data tab and select Get Data > Launch Power Query Editor. In Power BI, click Transform Data on the Home ribbon.
  2. Verify Your Sort Order: Before keeping bottom rows, you must ensure your data is sorted correctly. Power Query identifies the "bottom" based on the physical position of the rows in the current preview. If you want the most recent dates, click the filter dropdown on your Date column and select Sort Descending (to put newest at the top) or Sort Ascending (to put newest at the bottom). Since we are using "Keep Bottom Rows," you typically want your most relevant data at the bottom of the list.
  3. Locate the Keep Rows Menu: On the Home tab of the Power Query ribbon, look for the Reduce Rows group. Click the dropdown arrow next to the Keep Rows button. Note that menu labels may differ slightly depending on whether you are using a Mac, Windows, or the Power BI version of the editor.
  4. Select Keep Bottom Rows: From the dropdown menu, click Keep Bottom Rows. This will trigger a dialog box to appear in the center of your screen.
  5. Specify the Row Count: In the "Keep Bottom Rows" dialog box, enter the exact number of rows you want to remain in the dataset. For example, if you only need the last 100 transactions of the year, type 100.
  6. Confirm the Action: Click OK. Power Query will immediately apply the transformation, removing all rows except for the number you specified at the bottom of the table.
  7. Check the Applied Steps Pane: Look at the Applied Steps list on the right side of the editor. You will see a new step named "Kept Bottom Rows." You can click the gear icon next to this step at any time to change the number of rows kept without having to redo the entire process.
  8. Load the Data: Once you have verified that the correct rows remain, click Close & Apply (Power BI) or Close & Load (Excel) to bring the filtered data back into your spreadsheet or model.

Common Mistakes

The most frequent error users make is forgetting to sort the data before applying the Keep Bottom Rows command. Power Query does not know what "bottom" means in terms of value; it only knows the physical position of the row. If your data is unsorted, keeping the bottom 10 rows will simply give you the last 10 rows of the file, which might be random entries or empty null values. Always apply a Sort Ascending or Descending step first to ensure the bottom rows are actually the ones you want.

Another common mistake is using Keep Bottom Rows on a dataset that has a varying number of total rows. If you hard-code the number "10" into the Keep Bottom Rows step, but your data grows over time, you will always only get the last 10. While this is often the goal, some users mistakenly use this when they actually want to remove a specific number of header rows (which should be done via Remove Top Rows) or when they want to filter by a specific date range (which should be done via the column filter). Confusing "Keep" with "Remove" is also a frequent slip; remember that "Keep Bottom" deletes everything else, while "Remove Bottom" deletes only those specific rows.

Tips

For those dealing with dynamic datasets where the number of rows to keep changes, you can modify the M-code in the formula bar. Instead of a static number like 10, you can reference a parameter or a calculated value from another table. This allows your query to automatically adjust the number of rows it keeps based on a variable you define elsewhere in your workbook.

If you are trying to keep the bottom rows based on a specific condition (like all rows from the last 30 days) rather than a fixed number, avoid the Keep Bottom Rows tool entirely. Instead, use the Date Filter > In the Previous... option. This is much more robust than counting rows because it relies on the actual data values rather than the row index.

To speed up performance on massive datasets, try to perform your filtering and row reduction as early as possible in the Applied Steps list. Reducing the row count early means Power Query has less data to process for subsequent steps like merging, pivoting, or calculating custom columns, which significantly reduces memory usage and refresh times.

Troubleshooting

If you find that the wrong rows are being kept, the first thing to check is the sort order. Go back to the step immediately preceding "Kept Bottom Rows" in the Applied Steps pane. Ensure the column you are sorting by is correctly typed (e.g., Date type for dates, Decimal for numbers). If a date column is typed as "Text," the sort will be alphabetical rather than chronological, causing the bottom rows to be incorrect.

If the Keep Bottom Rows step is causing an error or slowing down your system, check if you have a "Sort" step that is breaking "Query Folding." In some SQL databases, sorting a massive table before keeping rows can force Power Query to download the entire table into memory before it can determine which rows are at the bottom. If this happens, try to apply a filter to narrow the dataset first, then sort, then keep the bottom rows.

If you see empty rows at the bottom of your result, your source data likely contains trailing nulls or empty cells. To fix this, apply a "Remove Empty" filter to your primary key column before you use the Keep Bottom Rows command. This ensures that you are keeping the last 10 rows of actual data, not the last 10 empty rows of the spreadsheet.

Frequently Asked Questions

Can I keep the bottom rows based on a date instead of a number?

The Keep Bottom Rows tool only accepts a numeric count of rows. To keep rows based on a date, use the filter arrow on the date column and select Date Filters > After... or In the Previous... to isolate the timeframe you need.

Does keeping bottom rows delete the data from the original source file?

No. Power Query is a non-destructive transformation tool. It reads the data from the source and applies a set of instructions to the view of that data. Your original Excel or CSV file remains completely untouched.

What happens if I enter a number larger than the total number of rows?

If you tell Power Query to keep the bottom 1,000 rows but your table only has 500, it will simply keep all 500 rows. It will not generate errors or create blank rows to fill the gap.

Can I use this to keep the last few entries of every category?

Not with the standard Keep Bottom Rows button, as that applies to the entire table. To do this for categories, you would need to Group By the category, use the All Rows operation, and then write a custom function to keep the bottom N rows of each nested table.

Is there a difference between Remove Top Rows and Keep Bottom Rows?

Yes. Remove Top Rows deletes a specific number of rows from the top and keeps everything else regardless of how long the table is. Keep Bottom Rows deletes everything except for the specific number of rows at the end of the table.