Null or missing values in a dataset can affect calculations, resulting in inaccurate data analysis and reporting.
Using Power Query, you can remove null values from your dataset, ensuring it is clean, consistent, and reliable for accurate analysis and reporting.
I will show you how to use Power Query to remove null values from a dataset in various scenarios.
Scenario #1: Removing Null Values from a Single-Column Dataset
Suppose you have the single-column dataset below with missing or null values in rows 4, 7, and 10.
You want to use Power Query to remove the null values.
Here’s how you can do it:
- Select the dataset.
- Open the Data tab and click the From Table/Range option on the Get & Transform Data group.
The above step opens the Create Table dialog box with the dataset’s reference filled in and the ‘My table has headers’ checkbox selected.
- Click OK on the Create Table dialog box.
The above step converts the data range to a table (if it wasn’t a table already) and loads the data onto the Power Query Editor.
- Click the filter and sort button with a down arrow icon in the header row, uncheck the ‘null’ checkbox, and click OK.
The above step filters out the null values from the dataset.
- On the Home tab, click the Close & Load button.
The above step closes the Power Query Editor and loads the dataset without null values onto the destination worksheet.
Scenario #2: Removing Null Values from Particular Columns in Specific Rows
Suppose you have the dataset below with null values in particular columns of rows 4, 7, and 10.
You want to use Power Query to remove the null values.
Here’s how you can do it:
- Load the dataset onto the Power Query Editor using steps 1 to 3 in the ‘ Use Power Query to Remove Null Values from a Single-Column Dataset’ section.
The above step loads the dataset onto the Power Query Editor.
- Filter out null values in each column as described in step 4 of the ‘ Use Power Query to Remove Null Values from a Single-Column Dataset’ section.
The above step filters out null values in each column of the dataset.
- On the Home tab, click the Close & Load button.
The above step closes the Power Query Editor and loads the dataset without null values onto the destination worksheet.
Scenario #3: Removing Null Values from All Columns in Specific Rows
Suppose you have the dataset below, where rows 4, 7, and 10 have null values in all columns.
You want to use Power Query to remove the empty rows from the dataset.
You can use the steps below to do it.
- Select the dataset and load it into the Power Query Editor as outlined in steps 1–3 of the ‘Use Power Query to Remove Null Values from a Single-Column Dataset’ section.
The above step loads the dataset onto the Power Query Editor.
- Click the Home tab, open the Remove Rows drop-down list on the Reduce Rows group, and select the Remove Blank Rows option.
The above step removes the rows with null values in all columns from the dataset.
- On the Home tab, click the Close & Load button.
The above step closes the Power Query Editor and loads the dataset without empty rows onto the destination worksheet.
Scenario #4: Use Power Query to Remove Null Values from All Rows in a Specific Column
Suppose you have the dataset below with missing or null values in all rows of column C.
You want to use Power Query to remove null values from all the rows of column C.
You can use the steps below to do the job:
- Load the dataset onto the Power Query Editor using steps 1 to 3 in the ‘ Use Power Query to Remove Null Values from a Single-Column Dataset’ section.
The above step loads the dataset onto the Power Query Editor.
- Select the ‘Outstanding Balance’ column by clicking its header.
- On the Home tab, click the Remove Columns option on the Manage Columns group.
The above step removes the selected column from the table, effectively removing the null values from all its rows.
- On the Home tab, click the Close & Load button.
The above step closes the Power Query Editor and loads the dataset without the empty column onto the destination worksheet.
I have shown you how to remove null values in Power Query in various scenarios. I hope you found the tutorial helpful.
Other articles you may also like: