---
title: "Convert set of strings to numbers in an expression"
url: "https://openforis.support/questions/68/convert-set-of-strings-to-numbers-in-an-expression"
tags: ["collect"]
status: "accepted"
score: 0
answer_count: 1
asked: "2014-10-22T09:07:11"
last_activity: "2014-10-22T11:51:48"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# Convert set of strings to numbers in an expression

Asked by Andras on 2014-10-22

Hi,

I have a code attribute with codes 1,2,...,10 in a multiple entity. When the user adds "n" entities to the form, the sum of the code values from 1 to "n" have to add up to 10.

I'd like to check the sum of these code values in a separate attribute. Since codes in code lists are strings, the values should be converted to numbers to be able to sum them. So I figured this should work:

Custom error check, expression: sum(number(parent()/stand/share)) = 10

However I get an error in the preview window: [RPC Fault faultString="Invalid argument type for 'sum': java.lang.Double"...

Is it possible to convert a set of strings to numbers? How can I do this? I would like to keep code list instead of a numeric attribute, if it's possible.

Thanks for your help!


## Accepted answer (score 0, by Stefano (OF) on 2014-10-22)

Link: https://openforis.support/questions/68/convert-set-of-strings-to-numbers-in-an-expression/70

Hi Andras,

you can solve this issue by adding a new **hidden calculated attribute** that will transform your *share* code value into a number, for example *share_num* with an expression like **number(share)** and then you can use that attribute in the custom check expression, that will become something like **sum(parent()/stand/share_num) = 10**.

Thanks!
