Calculation in the survey

(Giri) #1


I am struck here. Guys please guide me here...
I have a calculation
var 1
var 2
var 3
var 4... The sum of all should be reflected while entering, how can I make this??

var 1: 40
var 2: 0
var 3: 20
var 4: 60 (fill automatically instead of typing again)

(Dr. Gareth S. Bestor) #2

Try something like this for var4:

readonly = true

so that user cant change it. And

calculate = coalesce(${var1},0) + coalesce(${var2},0) + coalesce(${var3},0)

I added coalesce() so that you get a total showing as soon as you start entering any of the values. Otherwise the others will return NaN, which will blow your total until you set all three to have a specific value.

Here's a simple form that you can test on XLSForm Online:
sum.xls (19 KB)

(Giri) #3

Hi, thanks for the response.

I used the same in XLS. But I am getting ascii error while decode.

test.xlsx (9.6 KB)

Please help me to sort.
Thanks in advance..