Power Query Tip: Quickly Delete Every Null Column Each Time
Power BI
Jun 21, 2025 5:20 AM

Power Query Tip: Quickly Delete Every Null Column Each Time

by HubSite 365 about Excel Off The Grid

Excel Off The Grid will show you how to work smarter, not harder with Microsoft Excel.

Power Query technique: Remove all null columns, create custom functions. Themes: data cleaning, efficiency. Products: Excel

Key insights

  • Power Query is a Microsoft tool for importing, shaping, and transforming data in Excel and Power BI. It helps users clean and prepare data from different sources.

  • The main trick shown is to instantly remove all columns that contain only null values, making large datasets easier to manage and analyze.

  • This method uses the Table.Profile function to get metadata about each column, including how many values are present (Count) and how many are null (NullCount). Columns where Count minus NullCount equals zero are completely empty.

  • The approach is dynamic: it automatically finds and removes empty columns using Table.RemoveColumns, so you do not need to check or select them manually, saving time and effort.

  • This technique improves efficiency by reducing the size of your dataset, which can speed up loading times and make further analysis simpler in both Excel and Power BI workflows.

  • You can turn this process into a reusable custom function in Power Query, making it easy to apply across different projects whenever you need to clean similar data.

Introduction to Power Query’s Null Column Removal Trick

In a recent YouTube video by Excel Off The Grid, viewers were introduced to a powerful method for cleaning data in Microsoft Power Query. The technique focuses on automatically removing columns that contain only null values from a dataset. This is especially beneficial when working with large and wide tables, where empty columns can clutter analysis and slow down performance. As organizations continue to rely on data-driven decisions, efficient data cleaning steps like this have become highly valuable.

The video walks users through the logic behind this trick, making it accessible even for those who are not advanced Power Query users. By demonstrating the process step by step, Excel Off The Grid shows how to streamline data preparation and ensure that only meaningful information remains in your tables.

Understanding the Underlying Technology

Power Query is a versatile data connection and transformation tool built into Microsoft Excel and Power BI. It allows users to import data from various sources and reshape it as needed. One common challenge in data preparation is dealing with columns that contain no useful information — specifically, those filled entirely with null values. Manually identifying and removing such columns can be time-consuming, especially when dealing with complex datasets.

The featured technique leverages Power Query’s M language to automate this process. By using built-in functions, users can quickly scan their tables and eliminate any columns that do not contribute data, making the workflow more efficient and less prone to errors.

Step-by-Step Process: How the Trick Works

At the heart of this method is the Table.Profile function. This feature provides detailed metadata about each column in a table, including the total number of rows (Count) and the number of null entries (NullCount). By comparing these two values, Power Query can determine which columns are completely empty.

The process involves generating a profile of the table, filtering out columns where the count of non-null values is zero, and then removing those columns using Table.RemoveColumns. This approach is dynamic, adjusting automatically to any changes in the data structure or size, and it eliminates the need for manual checks.

A notable advantage here is that this method does not require unpivoting and repivoting data, which can be slow and cumbersome for large tables. Instead, it relies on efficient metadata analysis, making it suitable for both small and enterprise-level datasets.

Benefits and Tradeoffs of the Approach

One of the main benefits of this trick is its ability to automate what would otherwise be a tedious manual task. By removing all-null columns at the query stage, users can simplify their datasets and reduce unnecessary processing. This not only speeds up data loading but also makes subsequent analysis more straightforward.

However, there are tradeoffs to consider. While the method is highly effective for identifying and removing columns that are completely empty, it does not address the issue of columns with a mix of null and non-null values. For those cases, additional data cleaning steps—such as replacing nulls or filtering rows—may be necessary. Moreover, users must pay attention to column name casing, as Power Query is case-sensitive and mismatched names could lead to unintended results.

Reusable Custom Functions and Practical Tips

A significant enhancement discussed in the video is the ability to wrap this logic into a custom function. By doing so, users can easily apply the same cleaning step across multiple queries or projects without rewriting code each time. This promotes consistency and saves valuable development time, especially in environments where similar data structures are encountered frequently.

Additionally, it’s recommended to review the output after applying this method to ensure that only the intended columns have been removed. If further handling of null values within surviving columns is needed, Power Query offers functions like the coalesce operator to replace nulls with default values, providing flexibility for different data scenarios.

Conclusion: A Modern, Efficient Solution for Data Cleaning

The "Power Query Trick: Instantly Remove All Null Columns!" as presented by Excel Off The Grid is a practical and elegant solution for streamlining data cleaning in Power Query. By utilizing Table.Profile and Table.RemoveColumns, users can quickly eliminate empty columns, resulting in cleaner, more manageable datasets. This approach stands out for its efficiency and adaptability, making it a valuable addition to any data analyst’s toolkit.

As data complexity grows, automated solutions like these help maintain high-quality, actionable datasets without unnecessary manual intervention. For anyone serious about working efficiently in Power Query, mastering this trick is a clear step forward.

Power BI - Power Query Tip: Quickly Delete Every Null Column Each Time

Keywords

Power Query remove null columns Power Query tips Power Query tricks data cleaning Power BI Power Query tutorial Excel Power Query filter null columns