Power Query Not Null: How to Filter Out Null Values
In this article
To remove null values in Power Query, click the filter arrow in the column header and uncheck the "null" box, or use the "Remove Empty" option from the filter menu. This process ensures your datasets are clean by excluding rows where essential data is missing, preventing errors in calculations and improving the accuracy of your data visualizations.
Power Query is a powerful data transformation engine used in Excel and Power BI. One of the most common tasks in data cleaning is handling "nulls." In Power Query, a null is not the same as a blank string or a zero; it represents the absolute absence of a value. When you perform a "not null" operation, you are instructing the engine to discard any record that lacks a value in a specific column. This is critical because nulls can cause mathematical errors, break joins between tables, or create unsightly gaps in reports.
What You'll Need
- Microsoft Excel (with Power Query installed) or Power BI Desktop.
- A dataset imported into the Power Query Editor (via Get Data).
- A column containing the null values you wish to filter.
Step-by-Step
- 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.
- Identify the Target Column: Browse your table to find the column that contains the
nullvalues. These are typically displayed in italics as null. - 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 may differ slightly depending on your software version or region.
- Deselect Nulls: In the dropdown list of unique values, scroll down to find the checkbox labeled "(null)". Uncheck this box. This tells Power Query to only keep rows where the value is NOT null.
- Apply the Filter: Click OK. You will notice that the rows containing nulls disappear from the preview window, and a new step called "Filtered Rows" is added to the Applied Steps pane on the right.
- Alternative Method (Remove Empty): Instead of unchecking a box, you can click the filter arrow and select Text Filters > Does Not Equal... then leave the value box empty, or simply select "Remove Empty" if available in your specific version's filter shortcuts.
- Verify the Data: Scroll through your data or check the row count at the bottom left of the screen to ensure the nulls have been removed and that you haven't accidentally filtered out valid data.
- Load the Data: Once satisfied, click Close & Apply (Power BI) or Close & Load (Excel) to bring the cleaned data into your workbook or model.
Common Mistakes
One of the most frequent errors is confusing a null value with an empty string (a cell that looks empty but contains a "" value). If you uncheck "null" in the filter menu but still see empty cells, those cells are likely empty strings. To fix this, you must first use the "Replace Values" feature to replace empty strings with null, and then apply the filter.
Another common mistake is filtering nulls too early in the transformation process. If you remove nulls from a primary key column before performing a merge (join), you may lose records that could have been matched using other criteria. Always consider whether a null represents a missing piece of information that should be discarded or a specific state (like "Not Applicable") that needs to be preserved for analysis.
Users also often forget that Power Query is case-sensitive. While null is a reserved keyword and usually handled automatically, if you are writing a custom M-code formula like if [Column] <> null then ..., you must ensure null is written in lowercase. Writing NULL or Null will result in a syntax error because the M language does not recognize those variations.
Tips
For larger datasets, using the "Remove Empty" option is often faster than manually unchecking the null box, as it handles both nulls and empty strings in one action. This is particularly useful when dealing with CSV imports where blank cells are inconsistently interpreted.
If you need to remove rows that are null across multiple columns (i.e., the row is only kept if Column A OR Column B is not null), don't use the header filters. Instead, go to the Add Column tab, create a Custom Column with a logic statement like if [Column1] = null and [Column2] = null then "Remove" else "Keep", and then filter that new column for "Keep".
To keep your Applied Steps pane clean, you can rename the "Filtered Rows" step. Right-click the step in the pane and select Rename. Call it something descriptive like "Removed Null Customer IDs". This makes it much easier for other users (or your future self) to understand the data cleaning logic when auditing the query later.
Troubleshooting
If the null values are still appearing after you have applied the filter, first check if the values are actually the word "null" written as text rather than a true Power Query null. If they are text, you will see them in the filter list as "null" without the italics. In this case, uncheck the text version of the word.
If your data disappears entirely after filtering, you may have a data type mismatch. Ensure the column is set to the correct type (e.g., Text, Whole Number, or Date) before filtering. If a column is set to "Any", Power Query may struggle to consistently identify what constitutes a null value across different data sources.
If the filter is slowing down your performance significantly, check if you are using "Foldable" queries. If you are connecting to a SQL database, Power Query tries to push the "not null" filter back to the server (Query Folding). If you have added a complex custom step before the filter, folding might break, forcing Power Query to download millions of rows before filtering them locally. Try moving the "Filtered Rows" step as high up in the Applied Steps list as possible.
Frequently Asked Questions
What is the difference between null and blank in Power Query?
A null is a technical marker indicating that no value exists for that field. A blank (empty string) is actually a value—it is a piece of text with zero characters. They look identical in the grid but are treated differently by the engine.
Can I replace nulls instead of removing them?
Yes. Instead of filtering, right-click the column header and select "Replace Values". In the "Value to Find" box, type null, and in the "Replace With" box, enter your desired value (e.g., 0 for numbers or "Unknown" for text).
How do I filter for rows that ARE null?
Follow the same steps as the "not null" process, but instead of unchecking the null box, uncheck everything else and leave only the "(null)" box checked. This isolates the missing data for investigation.
Does filtering nulls delete the data from my 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. Your original Excel file, CSV, or SQL database remains completely unchanged.
Why does my filter not work on some rows?
This usually happens when there are hidden characters, such as non-breaking spaces or carriage returns, in the cell. The cell looks empty, but it contains an invisible character, so Power Query does not consider it null. Use the "Trim" or "Clean" functions under the Transform tab before filtering.