Forum Discussion
Count columns that are non-null, non-blank, non-zero
- 4 years ago
Personally, I would try the unpivot route first and try other methods if that didn't work efficiently.
If you go with a custom column, I'd do this to avoid the extra replacement step:
List.Count(List.Difference(List.Range(Record.FieldValues(_),3), {null, "", 0})) - Anonymous4 years ago
My apologies, took me a while to come back and fully test (we were short-staffed/recent turnover). The solution you gave me was almost there. It wasn't counting correctly when it came across rows with nulls in all columns. But this is what I modified it to (added List.RemoveNulls).
= Table.AddColumn(#"Changed Type", "NullBlankSpaceZero", each List.Count(List.RemoveNulls(List.Difference(List.Range(Record.FieldValues(_),2), {null, "", " ", 0}))))
note: there are some small differences from what I initially gave as an example that's why I adjusted field values and list diff compare list.
Thanks again! your reply set me on the right path
Personally, I would try the unpivot route first and try other methods if that didn't work efficiently.
If you go with a custom column, I'd do this to avoid the extra replacement step:
List.Count(List.Difference(List.Range(Record.FieldValues(_),3), {null, "", 0}))My apologies, took me a while to come back and fully test (we were short-staffed/recent turnover). The solution you gave me was almost there. It wasn't counting correctly when it came across rows with nulls in all columns. But this is what I modified it to (added List.RemoveNulls).
= Table.AddColumn(#"Changed Type", "NullBlankSpaceZero", each List.Count(List.RemoveNulls(List.Difference(List.Range(Record.FieldValues(_),2), {null, "", " ", 0}))))
note: there are some small differences from what I initially gave as an example that's why I adjusted field values and list diff compare list.
Thanks again! your reply set me on the right path