Power Query Remove Rows Based on Value: Complete Guide
In this article
To remove rows based on a value in Power Query, click the filter arrow in the column header of the target column, uncheck the values you want to exclude, and click OK. This action creates a filtered rows step in your query sequence, ensuring that every time the data refreshes, those specific values are automatically stripped out before the data loads into your spreadsheet or data model.
Removing rows based on specific values is one of the most fundamental data cleansing tasks in Power Query. Whether you are dealing with "null" values that break your calculations, "Error" strings from a failed import, or specific categories of data that are irrelevant to your current report, filtering allows you to shape your dataset without altering the original source file. Because Power Query records these actions as a series of steps, you do not have to repeat the process manually every time your source data updates; the engine simply reapplies the filter to the new data stream.
What You'll Need
- A dataset imported into Power Query (available in Excel via the Data tab or within Power BI Desktop).
- A clear understanding of which column contains the values you wish to remove.
- Knowledge of whether you want to remove a single specific value, a list of values, or values that meet a certain logical condition (e.g., all values greater than 100).
Step-by-Step
- Open the Power Query Editor: In Excel, go to the Data tab and select Get Data > Launch Power Query Editor. If your data is already loaded, double-click the query name in the Queries & Connections pane to reopen the editor.
- Locate the Target Column: Scroll through your table to find the column that contains the values you want to remove. For example, if you want to remove all rows where the "Status" is "Cancelled", locate the Status column.
- Access the Filter Menu: Click the small downward-pointing arrow (the filter icon) located on the right side of the column header. Note that menu labels and icons may vary slightly depending on your version of Excel or Power BI.
- Select Values to Remove: A dropdown list will appear showing all unique values present in that column. Uncheck the box next to the value(s) you want to remove. For instance, uncheck "Cancelled". If you have a very long list of values, you can use the search box within the filter menu to find the specific term quickly.
- Apply the Filter: Click OK. Power Query will immediately process the request and hide the rows containing the unchecked values.
- Verify the Applied Step: Look at the "Applied Steps" pane on the right side of the screen. You will see a new step titled "Filtered Rows". This confirms that the operation was recorded.
- Load the Data: Once you have verified that the correct rows are gone, click Close & Apply (in Power BI) or Close & Load (in Excel) to bring the cleaned data back into your worksheet.
Common Mistakes
One of the most frequent errors users make is forgetting that Power Query is case-sensitive. If you filter out "Cancelled" but your data also contains "cancelled" (lowercase), the lowercase versions will remain in your dataset. To avoid this, it is a best practice to right-click the column header, select Transform, and choose Capitalize Each Word or Uppercase before applying your filter.
Another common mistake is removing rows too early in the query sequence. If you remove rows based on a value and then later perform a merge or a join with another table, you might lose the ability to match records that were filtered out. Generally, you should perform your primary data cleaning (like removing errors or nulls) early, but wait until after your joins to remove specific business-logic values if those values are needed for the matching process.
Users also often confuse "Remove Rows" with "Filter Rows". While the result looks the same, using the filter menu is the standard way to remove rows based on a value. There is a separate "Remove Rows" button in the Home tab, but that is typically used for removing the top X rows or bottom X rows, not for filtering based on specific cell content.
Tips
For more complex removals, avoid the simple checkbox list and use "Text Filters" or "Number Filters". By selecting Text Filters > Does Not Equal, you can specify a value to remove that might not be present in the current preview but could appear in future data refreshes. This makes your query more robust.
If you need to remove rows based on multiple conditions across different columns, you can apply multiple filters. For example, you can filter out "Cancelled" in the Status column and then filter out "0" in the Amount column. Power Query will treat these as "AND" logic, meaning a row is removed if it meets either of those criteria.
To handle "null" values specifically, you can use the filter menu to uncheck "null". However, if you want to remove rows where the value is blank but not necessarily null (like an empty string), you may need to use the "Replace Values" feature first to turn blanks into nulls, then filter the nulls out.
Troubleshooting
If you apply a filter but the rows you wanted to remove are still appearing, first check for leading or trailing spaces. A value that looks like "Cancelled" might actually be "Cancelled " (with a space at the end). To fix this, right-click the column header, select Transform, and click Trim. This removes all invisible spaces from the start and end of the text, allowing the filter to work correctly.
If the filter is removing too many rows, check the "Applied Steps" pane. You may have accidentally applied a filter to a different column earlier in the process. You can click the gear icon next to the "Filtered Rows" step to modify the criteria or click the "X" next to the step to delete it entirely and start over.
If your query is running very slowly after adding a filter, it may be because the filter is forcing Power Query to download the entire dataset from the source before filtering (this is known as breaking "Query Folding"). If you are using a SQL database, try to ensure the filter is one of the first steps in your query so that the database handles the filtering before the data even reaches your computer.
Frequently Asked Questions
Can I remove rows based on a value in another table?
Not directly through the filter menu. You must first perform a Merge (Join) between the two tables. Once the second table is expanded into the first, you can then filter the resulting column to remove the rows you don't want.
Will removing rows in Power Query delete the data in my original Excel file?
No. Power Query is a non-destructive tool. It reads the data from the source and applies transformations in a virtual layer. Your original source file remains completely untouched.
How do I remove rows that contain a specific word but aren't exactly that word?
Instead of unchecking a box in the list, go to the filter arrow, select Text Filters, and choose "Does Not Contain". Type the word you want to exclude. Any row containing that sequence of characters will be removed.
Is there a way to remove rows based on a dynamic value?
Yes, by using a Parameter. You can create a Power Query parameter and then edit the M-code in the formula bar to replace the hard-coded value (e.g., "Cancelled") with the name of your parameter. This allows you to change the value to be removed without opening the Power Query Editor.
What happens if the value I filtered out changes name in the source data?
The filter will no longer find that specific value, and the rows will start appearing in your report again. To prevent this, use "Contains" or "Starts With" filters if the naming convention is slightly inconsistent.