Forum Discussion
Formula to Automatically Remove Blank Columns from a table
- 4 years ago
This is a context reference issue. The problem here is that M thinks you want to take the [Data] column from the column name. You can clear this up by using a new name for your selection function.
Table.SelectColumns( [Data], List.Select( Table.ColumnNames([Data]), (colName) => List.NonNullCount(Table.Column([Data], colName)) > 0 ) )Note: List.IsEmpty returns FALSE for a column of null values since, e.g., {null, null} is not the same as {}.
This is a context reference issue. The problem here is that M thinks you want to take the [Data] column from the column name. You can clear this up by using a new name for your selection function.
Table.SelectColumns(
[Data],
List.Select(
Table.ColumnNames([Data]),
(colName) => List.NonNullCount(Table.Column([Data], colName)) > 0
)
)
Note: List.IsEmpty returns FALSE for a column of null values since, e.g., {null, null} is not the same as {}.
- one_eon4 years agoFrequent Visitor
Wow, that fixed it. Thank you. And also thanks for the tip about "List.IsEmpty". I'm sure that would have been my next question.
I had tried declaring a variable with 'let' but that hadn't worked either. I guess I have to learn more about when to use variables and when to use functions in power query, as I have a hard time telling the difference between the two.
Not all the tables successfully rendered, as a few of them have a "DataFormat.Error: Invalid cell value '#DIV/0!'." But I suspect that is due to something in the file itself. I will try to replace the errors in power query and run it again.
Again, thank you.