Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Filter Out Rows: A Complete Step-by-Step Guide

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To filter out rows in Power Query, click the drop-down arrow in the header of the column you want to filter, uncheck the values you wish to remove, and click OK. This process removes unwanted data from your dataset before it is loaded into your Excel worksheet or Power BI model, ensuring your reports remain clean, performant, and focused only on relevant information. Filtering is a foundational step in data transformation that reduces the memory footprint of your file and prevents noise from skewing your analysis.

What You'll Need

  • Microsoft Excel (with Power Query installed) or Power BI Desktop.
  • A data source already connected to the Power Query Editor (such as a CSV, Excel table, SQL database, or Web folder).
  • A clear understanding of which specific values or conditions define the "unwanted" rows you intend to remove.

Step-by-Step

  1. Open the Power Query Editor: In Excel, go to the Data tab and select Get Data > Launch Power Query Editor. If you already have a query, double-click the query name in the Queries & Connections pane to open the editor window.
  2. Identify the Target Column: Scroll through your data preview to find the column containing the values you want to filter. For example, if you have a "Status" column and want to remove all rows marked as "Cancelled," locate that specific column.
  3. Access the Filter Menu: Click the small downward-pointing arrow (the filter icon) located on the right side of the column header. This opens a checklist of all unique values currently present in that column.
  4. Deselect Unwanted Values: In the list of values, uncheck the boxes next to the items you want to filter out. If you want to remove "Cancelled" and "Pending," uncheck those two boxes. All other checked items will be kept in the dataset.
  5. Apply the Filter: Click OK. Power Query will immediately process the request and remove the rows. You will notice a new step appearing in the "Applied Steps" pane on the right side of the screen, typically labeled as "Filtered Rows."
  6. Using Text Filters for Complex Rules: If your dataset has thousands of unique values, unchecking boxes manually is inefficient. Instead, click the filter arrow, hover over Text Filters, and select a specific rule. For example, choose "Does Not Equal..." and type the word "Cancelled" into the box. This creates a dynamic rule that will also filter out "Cancelled" rows in future data refreshes, even if new variations of other data appear.
  7. Using Number Filters for Ranges: For numeric columns, click the filter arrow and hover over Number Filters. You can select "Does Not Equal," "Is Not Between," or "Is Not Greater Than." For instance, if you want to filter out all transactions under 1 dollar, select "Is Greater Than" and enter 1.
  8. Filtering Out Nulls or Blanks: To remove empty rows, click the filter arrow and uncheck the "(null)" or "(blank)" option at the bottom of the list. Alternatively, use Text Filters > Does Not Equal and leave the value box empty.
  9. Verify the Results: Scan the remaining rows in the preview window to ensure only the desired data remains. Check the row count at the bottom left of the screen to see how many rows were removed.
  10. Load the Data: Once the filtering is complete, click Close & Apply (in Power BI) or Close & Load (in Excel) to bring the cleaned data into your main workspace.

Common Mistakes

One of the most frequent errors is filtering by selecting specific checkboxes in a dataset that is expected to grow. When you uncheck "Cancelled" from a list, Power Query records the specific list of items to keep. If a new status called "Void" is added to your source data next month, Power Query may not know how to handle it depending on how the filter was applied. To avoid this, always use the "Does Not Equal" logic for values you want to exclude, rather than selecting everything else to include.

Another common mistake is filtering rows too late in the sequence of Applied Steps. If you perform complex merges, pivots, or custom column calculations before filtering out the junk rows, Power Query has to perform those calculations on every single row—including the ones you eventually delete. This significantly slows down the refresh time. The general rule of thumb is to filter out unnecessary rows as early as possible in the query process to optimize performance.

Users also often confuse "Filtering" with "Removing Columns." Filtering removes horizontal rows based on criteria; removing columns deletes vertical categories of data. Ensure you are using the filter arrow in the header rather than right-clicking the column to remove it entirely.

Tips

To make your queries easier to maintain, rename your "Filtered Rows" step. Right-click the step in the Applied Steps pane and select Rename. Change it to something descriptive like "Removed Cancelled Orders." This helps other users (or your future self) understand exactly why those rows were removed without having to click into the step settings.

If you need to filter based on multiple columns, you can apply filters sequentially. Filter the first column, then move to the second column and apply another filter. Power Query treats these as "AND" logic, meaning a row must meet all filter criteria to remain in the dataset. If you need "OR" logic (e.g., keep rows where Status is "Active" OR Region is "North"), you will need to use the Advanced filter options or create a custom conditional column first.

For those dealing with messy text data, use the "Transform" tab to trim whitespace or convert text to lowercase before filtering. If some rows say "Cancelled" and others say "cancelled " (with a trailing space), a standard filter might miss some of them. Cleaning the text first ensures your filter catches every instance of the unwanted value.

Troubleshooting

If you apply a filter but the unwanted rows are still appearing, first check for leading or trailing spaces in your source data. A value that looks like "Closed" might actually be "Closed ". To fix this, right-click the column header, select Transform, and click Trim. Then, re-apply your filter.

If the filter causes an error message saying "The column [ColumnName] of the table wasn't found," it means the source data has changed. The column you filtered might have been renamed or deleted in the original file. To fix this, go to the Applied Steps pane, click the gear icon next to the "Filtered Rows" step, and re-select the correct column or update the filter criteria.

If your query is running extremely slowly after adding a filter, check if you are using a "Folding" compatible data source (like SQL). If you use a complex custom filter that Power Query cannot translate into a SQL query, it will download the entire dataset to your local machine before filtering. Try to use the simplest filter options provided in the menu to ensure the filtering happens on the server side (Query Folding) rather than on your computer.

If you accidentally filtered out too much data, do not panic. You do not need to start over. Simply go to the Applied Steps pane on the right and click the small "X" next to the "Filtered Rows" step. This will instantly revert the data to its state before the filter was applied.

Frequently Asked Questions

Can I filter out rows based on a date range?

Yes. Click the filter arrow in a Date column, select Date Filters, and choose an option like "Between..." or "In the Previous..." to specify the exact timeframe you want to keep or exclude.

Will filtering rows delete the data from my original source file?

No. Power Query is a non-destructive tool. It reads the data from the source and applies transformations in a separate layer. Your original Excel or CSV file remains completely untouched.

How do I filter out rows that contain a specific word anywhere in the cell?

Click the filter arrow, go to Text Filters, and select "Does Not Contain..." then type the word. This will remove any row where that specific string appears, regardless of what else is in the cell.

Can I filter out rows based on a value in a different column?

Standard filters only look at the current column. To filter based on a different column, you must either filter that column separately or create a Custom Column with an IF statement that marks rows as "Keep" or "Remove," and then filter that new column.

What is the difference between "Remove Rows" and "Filter Rows"?

"Remove Rows" (found in the Home tab) is used for positional removal, such as removing the top 10 rows or removing duplicate rows. "Filter Rows" uses logic and values to decide which data to keep based on content.