Dataview showing Nan

I created this dataview table which will search for certain files & show some YAML. However, I have one field that is JavaScript calculated value from the front matter of that file. This field is showing NaN in the table.

for e.g (just adds S1+ A1 & shows the sum)
V1:: $= app.metadataCache.getFileCache(["S1"] + app.metadataCache.getFileCache(["A1"]

If you try to add numbers with either a string or an undefined field you’ll get the NaN value, so you’ll need to find that veie which causes the addition to fail.

Either that, or you need to ensure that every value you try to add is a number by n converting/forcing it. This runs the risk of masking erroneous text as a number.

Best way chard would be to list all the values you’re trying to sum, preferably with an extra typeof call to help you identify which value it fails at.

1 Like

Hi @ValiantOne ,

Out of curiosity, why are you using getAbstractFileByPath to get the current file?

The below inline query seems to do the same thing using Dataview’s internal lookup mechanism:

`$= dv.current().A1 + dv.current().S1`
1 Like

Thank you. I just took that from a code that picked online. I didn’t know there was a simpler way to do it.

1 Like