Power Query Editor Filter Rows: A Complete Guide
In this article
To filter rows in Power Query Editor, click the drop-down arrow in the column header of the data you want to refine, uncheck the values you wish to remove (or use Text, Number, or Date filters for specific logic), and click OK. This process removes unwanted data from your dataset before it is loaded into your spreadsheet or data model, ensuring your final report is clean, performant, and focused only on the relevant information.
Filtering rows is one of the most fundamental transformations in Power Query. Unlike filtering in a standard Excel table, which merely hides rows from view, filtering in Power Query actually instructs the engine to exclude those rows during the data import process. This is critical when dealing with massive datasets; by filtering out unnecessary rows early, you reduce the memory load on your computer and speed up the refresh time of your reports. Whether you are removing null values, isolating a specific date range, or excluding a particular category of product, the filtering tools allow you to create a precise subset of your original data source.
What You'll Need
- Microsoft Excel or Power BI Desktop installed on your machine.
- A data source already connected to Power Query (such as a CSV file, an Excel table, a SQL database, or a web folder).
- The Power Query Editor window open (accessible via the Data tab > Get Data > Launch Power Query Editor).
Step-by-Step
- Open the Power Query Editor: If you are starting from Excel, go to the Data tab on the ribbon and select Get Data, then choose Launch Power Query Editor. If you already have a query, double-click it in the Queries & Connections pane to open the editor.
- Locate the Target Column: Scroll through your dataset to find the column containing the criteria you want to filter. For example, if you only want sales data from the "East" region, locate the "Region" column.
- Access the Filter Menu: Click the small downward-pointing arrow (filter icon) located on the right side of the column header. A drop-down menu will appear. Note that labels and icons may differ slightly depending on whether you are using Power BI or different versions of Excel.
- Choose Your Filtering Method: You have two primary ways to filter here:
- Basic Checkboxes: A list of all unique values in that column is displayed. Uncheck the boxes for the values you want to exclude, or click Select All and then check only the specific values you want to keep.
- Logical Filters: Hover over the categories labeled Text Filters, Number Filters, or Date Filters (the label changes based on the data type of the column). This opens a sub-menu with logical operators such as "Equals," "Does Not Equal," "Begins With," "Is Greater Than," or "Between."
- Configure Logical Criteria: If you chose a logical filter (e.g., Number Filters > Greater Than), a dialog box will appear. Enter the specific value you want to use as your threshold. For instance, if you only want orders over $500, enter 500 in the value field.
- Apply the Filter: Click OK. You will notice that the rows not meeting your criteria disappear from the preview window immediately.
- Verify the Applied Step: Look at the Applied Steps pane on the right side of the editor. You will see a new step added, typically named "Filtered Rows." This confirms that the filter is now a permanent part of the data transformation sequence.
- Load the Data: Once you have filtered all necessary columns, go to the Home tab and click Close & Apply (Power BI) or Close & Load (Excel) to bring the filtered data into your worksheet or model.
Common Mistakes
One of the most frequent errors is filtering data based on a preview that is not representative of the entire dataset. By default, Power Query shows a preview of the first 1,000 rows. If you use the checkbox method, you might not see all possible values in your data. If a value doesn't appear in the list, it doesn't mean it isn't in your source; it just isn't in the first 1,000 rows. To avoid this, always use the logical filters (like "Does Not Equal") instead of unchecking boxes when working with large datasets.
Another common mistake is filtering rows too late in the sequence of Applied Steps. For example, if you perform a complex merge or a heavy calculation on millions of rows and then filter those rows down to a few hundred, you have wasted significant processing power. The general rule of thumb in Power Query is to "filter early and often." Moving your Filtered Rows step to the top of the Applied Steps list can drastically improve performance.
Users also frequently forget that Power Query is case-sensitive. If you apply a text filter for "Apple" but your data contains "apple" (lowercase), the lowercase version will be filtered out. This can lead to missing data in your final report without any error message appearing to warn you.
Tips
To handle the case-sensitivity issue mentioned above, transform your column to uppercase or lowercase before filtering. Right-click the column header, select Transform, and choose lowercase. Now, you can apply a filter for "apple" and be certain that all variations of the word are captured.
For more dynamic filtering, consider using Parameters. Instead of hard-coding a value like "2023" into your filter, you can create a Parameter in Power Query and link the filter to that parameter. This allows you to change the filter criteria from the main Excel or Power BI interface without having to open the Power Query Editor every time.
If you need to filter based on multiple columns, simply repeat the filtering process for each column. Power Query will add a separate "Filtered Rows" step for each column. If you need more complex "OR" logic (e.g., keep rows where Region is "East" OR Sales are over $1,000), you will need to click the formula bar (fx) and manually edit the M code to use the "or" operator, as the standard UI primarily handles "AND" logic when filtering multiple columns sequentially.
Troubleshooting
If your filter does not seem to be working, first check the data type of the column. If a column is set to "Any" or "Text" but contains numbers, the Number Filters option will not appear. Change the data type by clicking the icon to the left of the column header and selecting the correct type (e.g., Decimal Number or Date).
If you find that rows you intended to keep are missing, check the Applied Steps pane. You may have applied a filter in an earlier step that you forgot about. Click through the previous steps to see where the data disappeared. You can remove any unwanted filter by clicking the "X" icon next to the step name in the Applied Steps list.
If the Power Query Editor becomes extremely slow or freezes after applying a filter, it may be due to a lack of "Query Folding." Query Folding is when Power Query pushes the filter logic back to the source server (like SQL). If you have a step before the filter that breaks folding (like some complex custom functions), Power Query has to download all the data first and then filter it locally. Try moving the Filtered Rows step to the very beginning of your query to see if performance improves.
Frequently Asked Questions
Can I undo a filter in Power Query?
Yes. Unlike standard Excel where you might use Ctrl+Z, you undo a filter by going to the Applied Steps pane on the right and clicking the red "X" next to the "Filtered Rows" step.
Does filtering rows delete the data from the original source file?
No. Power Query is a read-only transformation tool. It creates a set of instructions on how to process the data, but it never modifies, deletes, or overwrites the original source file or database.
How do I filter for blank or null values?
Click the filter arrow in the column header. In the list of values, scroll to the bottom and uncheck "(null)" to remove blanks, or uncheck everything except "(null)" to see only the blank rows.
Can I filter rows based on the value of another column?
Not directly through the simple filter menu. To do this, you would typically create a Custom Column with an "if" statement (e.g., if [Column A] = "X" then 1 else 0) and then filter that new column for the value 1.
What is the difference between "Remove Rows" and "Filter Rows"?
"Remove Rows" (found in the Home tab) allows you to remove rows by position, such as removing the top 10 rows or removing duplicate rows. "Filter Rows" removes data based on specific values or logical conditions within the data itself.