Select to view content in your preferred language

Updating calculation from various fields

469
2
12-03-2019 09:58 AM
KerryKang1
Emerging Contributor

Hello all, 

I have a question for showing calculation result while data is being entered.

There is a label showing 'Total Value' where the values are added from item 1 - 10. My current calculation is

${item1} + ${item2}  + ${item3} +${item4} + ${item5}  + ${item6}+${item7} + ${item8}  + ${item9}+${item10}. 

The problem with this method is that the Total value is not updated until all 10 values are added. Users may enter values for all 10 items or maybe only 8 or even 5. How can I make the total value updated as each item value is entered, not waiting until the last item value is entered?

I could use repeat and  using sum for item but this will create nested repeat for my survey, and I cannot use as this survey needs to be opened through web browser.

Cheers,

0 Kudos
2 Replies
IsmaelChivite
Esri Notable Contributor

Hi. If any of the input values in your formula is null, the output will be null. To work around this you can:

* Set a default value of 0 to all questions (using the default XLSForm column)

* Modify your expression as follows:

coalesce(${item1},0) + coalesce(${item2},0)  + coalesce(${item3},0) ...

KerryKang1
Emerging Contributor

Hi Ismael, this method worked perfect. Thanks!

Cheers, 

0 Kudos