Forum Discussion
Dicken
Post Prodigy
2 months agoCounting nulls
Hi, counting null values, i have; = let alist =
{1,2,2,"a",null, null, 2,"a",3,2,null, "a"}
in
List.Count( alist) - List.NonNullCount( alist)
or
= let alist =
{1,2,2,"a",nul...
- 2 months ago
Hi Dicken,
For pure null values, I would keep your first approach. It is probably the cleanest and easiest to read:
let alist = {1,2,2,"a",null, null, 2,"a",3,2,null, "a"} in List.Count(alist) - List.NonNullCount(alist)List.NonNullCount is built to count non-null items, so total count minus non-null count gives the null count.
- 2 months ago
List.Accumulate(alist, 0, (i,x) => i + Number.From(x=null))
List.Sum(List.Transform( alist, each Number.From(_=null)))
Dicken
Post Prodigy
2 months agoa take on the accumulate version, so not to count but show where null;
= let alist = {"a",1,null, null,"a",3,"b"}
, t = "a"
in List.Accumulate( alist, {} , (s,c)=>
s & { Number.From( c = null ) } )