I want to show the total of the expenses, but I see that it does not add up the variables

Hola, he construido un cuestionario que tiene una sección sobre gastos pero quiero mostrar el total de los gastos, pero veo que no hace la suma de las variables. ¿pueden ayudarme?

Primero he colocado una pregunta donde el entrevistado debe seleccionar si ha realizado un tipo gastoa: A (si o No) , b (si o no), C (si o no). Posteriormente quiero que sume los gastos que ha colocado en las que ha seleccionado que Si. Pero al final no sale.

La expresión que he usado es ${p6211}+${p6221}+${p6231}+${p6241}+${p6251}+${p6261}
¿Debo colocar otra expresión si quiero que lo sume?
aQFd99WgocGk7UDdpWyJ39 (3).xlsx (24.9 KB)


As most items of the sum can be missing because they are filtered by relevant clauses, you may need to use number( coalesce(${p6211}, ‘0.0’) ) + …, and equally for all items in the sum. See ODK XForms Specification and ODK XForms Specification.
A corresponding formula would be if(${p6211} = ‘’. 0.0, ${p6211}) + if( …) + …

Hint: As decimals have limited IT accuracy, please, test the summation carefully, esp. with small numbers and many decimals.

Design hint:

  • I think the select_one sino should be required = true as you have a yes / no table here. (This is another reason for the need of the coalesce above, as the answers can be empty which are used later for the relevant).
  • These yes/no tables could also be designed as select_multiple. (Using relevant with selected(…)),
  • You don’t need to specify required = false, as this is the automatic default.

Your form has a syntax error: “The survey element named ‘Estamos_realizando_u_eriencia_al_respecto’ has no label or hint.” Don’t forget to check your forms during development and before deployment with the Online validator, please.

1 Like

@wroos, :clap: :heart: :partying_face:

Please can I have this in English

Please guide me on how to create something like this