Problem when performing arithmetic operations involving variables and db data

Hello, I am trying to perform simple operations like add, divide, multiply,… involving variables and/or database data and I can’t do it.
I’ve done and re-done everything several times betting that the problem was with me.
The data types are numeric but all operations or functions like SUM, MULTIPLY, DIVIDE etc return null or using the ‘+’ operator I get a text join operation.
So after a long time I started to analyze the debuger and realized that AppGyver stores everything as text, even the fields and variables indicated as numeric.
So I ran a test with the ‘NUMBER()’ function on each variable and data in the database and everything started working as it should.
So I can’t perform ‘SUM_BY_KEY(data.test, “number”)’ which always returns 0.

Is this the expected result in AppGyver, or is this a bug?

1 Like

Look here

Hi @LdF, there is a known issue that if you feed the variables from an input, they get stored as text since there is no separate number input (yet), but I haven’t seen this happen with numeric data pulled directly from a database. Would you be able to provide a screenshot of your data resource schema in the Data Configurator and another one of how the populated data variable looks in the debugger?

Meanwhile, a workaround to transform the data into a format you can use in the SUM_BY_KEY() formula:

MAP(data.list, SET_KEY(item, "keyToTransform", NUMBER(item.keyToTransform)))

or if you simply want to get the sum:

SUM(MAP(data.list, NUMBER(item.keyToTransform)))