Forum Discussion
Finding columns with only null values
- 4 years ago
Hi Anonymous
If you only want to know which columns are null columns, here is another method which doesn't require much M code knowledge.
In below table, Column C and D only contain null values. The table has 3 rows in total and its name is "Query1".
Then in the left-side Queries pane, right click your mouse and select New Query > Blank Query.
You will see a new query appear. In below image, Query2 is the new query. Input the following code in its formula bar. Replace yourTableName with the original table name.
= Table.Profile(yourTableName)You will get some summary statistics of each column in the new table. There is a "Count" column and "NullCount" column. "Count" column means the total rows in this column. "NullCount" means the number of null values in this column. If these two values are the same, it means this column only has null values.
Based on that, you can add a conditional column to compare two values. If they are equal, return "Yes". If not, return "No".
Then you can filter the new column to only have rows that value is "Yes". The most left column will tell you which columns only have null values.
I get this idea from the following blog. If you want to remove null columns in Power Query Editor, you can follow the detailed steps in this blog.
Dynamically Remove Null Columns in Power Query with M code (antmanbi.com)
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi Anonymous
If you only want to know which columns are null columns, here is another method which doesn't require much M code knowledge.
In below table, Column C and D only contain null values. The table has 3 rows in total and its name is "Query1".
Then in the left-side Queries pane, right click your mouse and select New Query > Blank Query.
You will see a new query appear. In below image, Query2 is the new query. Input the following code in its formula bar. Replace yourTableName with the original table name.
= Table.Profile(yourTableName)
You will get some summary statistics of each column in the new table. There is a "Count" column and "NullCount" column. "Count" column means the total rows in this column. "NullCount" means the number of null values in this column. If these two values are the same, it means this column only has null values.
Based on that, you can add a conditional column to compare two values. If they are equal, return "Yes". If not, return "No".
Then you can filter the new column to only have rows that value is "Yes". The most left column will tell you which columns only have null values.
I get this idea from the following blog. If you want to remove null columns in Power Query Editor, you can follow the detailed steps in this blog.
Dynamically Remove Null Columns in Power Query with M code (antmanbi.com)
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
- Anonymous4 years agoNot applicable
Thank you so much. It worked find 😁