0

I am building a survey form through KoboToolbox. The web forms are Enketo based. I have some questions of the following type (before comma is first column and first row is data titles in XLSform format):

type, name

begin_group,    group_farmexpenses_q5

note,   group_farmexpenses_q5_note

integer,    group_farmexpenses_q5_p1

text,   group_farmexpenses_q5_column_1

end_group,  

begin_group,    group_farmexpenses_q5_1

note,   group_farmexpenses_q5_1_note

integer,    group_farmexpenses_q5_1_p1

text,   group_farmexpenses_q5_1_column_1

end_group,

What i want to do is apply if statement for the integer values inside these two groups, however I get error. Here is what I do to apply if-statement :

if(${group_farmexpenses_q5_p1}=999, 0, ${group_farmexpenses_q5_p1}) if(${group_farmexpenses_q5_1_p1}=999, 0, ${group_farmexpenses_q5_1_p1})

since the above are calculate statements and each one is referred to as "expense1" and "expense2"

i then just add them

${expense1} + ${expense2}

I get error message:

if({group_farmexpenses_q5_1_p1} = 999, 0, /model/instance[1]/data/group_wx0mk24/group_farmexpenses_q5_1/group_farmexpenses_q5_1_p1 ), message: The expression is not a legal expression. (line: undefined, character: undefined)

Any ideas how to fix this? I think there should be an easy fix but I don't know much about XLSform structures.

Develop4Life
  • 7,581
  • 8
  • 58
  • 76
ZiaW
  • 47
  • 9
  • I found a solution through online search. instead of first conditoning and then adding, both can be done in one step: if(${fexp_q1} = 999, 0, ${fexp_q1}) + if(${fexp_q2} = 999, 0, ${fexp_q2}) – ZiaW Sep 12 '18 at 20:45
  • Glad you found a solution. I think your original had a syntax error. Maybe a forgotten $ character. – Martijn van de Rijdt Sep 12 '18 at 22:54

1 Answers1

0

Proposed solution through online search for @Ziaw. Instead of first conditioning and then adding, both can be done in one step:

calculated data field compute this

if(${fexp_q1} = 999, 0, ${fexp_q1}) + if(${fexp_q2} = 999, 0, ${fexp_q2})

Develop4Life
  • 7,581
  • 8
  • 58
  • 76