Sum of Metadata

Hello

I have a doubt about dataview … I am writting this

C::  5
C::  2
`= this["C"]`
`= sum(this["C"])`

And as expected this is my output in reading view

C:: 5
C:: 2
5, 2
7

However, when I do this:

A:: 1
B::  5
B::  `= 1 + this.A`
`= this["B"]`
`= sum(this["B"])`

It is not able to calculate correctly the last line

A:: 2
B:: 5
B:: 2
5, 2
52

It’s as if it concatenate the 5 and the 2 … I supose It treats them as strings…

Any hint ?

There are two different issues you’re facing writing stuff like this. Firstly, when doing sum(...) you need to make sure that you’re summing up numbers, and not texts. This can be often be done using something like `= sum(number(this.B))`.

Secondly, when you set an inline fields to a query, it stores the query, and not the result of the query, so the example with the second B would result in you attempting to sum a text value of 5, plus a query (not the result of “1 + A”). This issue is not easily worked around currently.

1 Like

Damn … Many thanks for you reply.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.