I’ve seen this in some circumstances, and if the value for some conditions of FLATTEN
and/or a WHERE
clause is falsy, the lines is not included.
What proved to be icky in your situation is that sum(...)
is valid to do on even an empty field, but if you do length( ... )
on that item, even within a choice()
it turns out to be a falsy value, and the line is ignored.
However, there are ways around it, so try out the following in a note of itself, and you’ll see some of the cases and alternatives to get values out even when they are not considered truthy.
## Base query
```dataview
TABLE WITHOUT ID item[0], item[1], typeof(item[1])
FLATTEN list(
["none", null],
["one", 1],
["two", [20, 22]]
) as item
WHERE file.name = this.file.name
```
## Check all types + average
```dataview
TABLE WITHOUT ID item[0], item[1], typeof(item[1]), mySum
FLATTEN list(
["none", null],
["one", 1],
["two", [20, 22]]
) as item
FLATTEN
choice( typeof(item[1]) = "number", item[1],
choice( typeof(item[1]) = "array", average(item[1]),
choice( !item[1] , 0, 999))) as mySum
WHERE file.name = this.file.name
```
## Default + average
```dataview
TABLE WITHOUT ID item[0], item[1], typeof(item[1]), mySum
FLATTEN list(
["none", null],
["one", 1],
["two", [20, 22]]
) as item
FLATTEN default(
choice(
typeof(item[1]) = "number",
item[1],
average(item[1])),
0) as mySum
WHERE file.name = this.file.name
```
## Just average
```dataview
TABLE WITHOUT ID item[0], item[1], typeof(item[1]), mySum
FLATTEN list(
["none", null],
["one", 1],
["two", [20, 22]]
) as item
FLATTEN
choice(
typeof(item[1]) = "number",
item[1],
average(item[1])) as mySum
WHERE file.name = this.file.name
```
So my recommendation is to use either average()
on its own, or in combination with default
.
With default
you’ll get a value when there’s no value for the field, and without you’ll just get an empty row returned.