Default option not working if the question is skipped

Hi,

In the survey sheet below you can see question with variable name
"total_mem" is skipped if *"totmem_check"=1. *The issue is if "total_mem"
is skipped, it leaves value of "total_mem" variable as empty (default=0 option
does not works if it is skipped). Is there any way/option which would allow
me to store value of total_mem=0 if question with variable name
"total_mem" is skipped, otherwise store the entered value (in case
total_mem not skipped).

Why I want to do this? If "tot_mem" variable is empty then "new.mems"
variable won't calculate value (correctly).

Survey Sheet
type name label hint relevant calculation default
select_one yes_no totmem_check Total members are ${totmem}? (totmem)
is the total number of members of organization which we are pulling from
baseline
integer total_mem Total members in organization? ${totmem_check}=2 0
calculate new.mems These are the number of new members in organization if(${total_mem}>${totmem},${total_mem}

  • ${totmem},0) 0

choices sheet
list name name label
yes_no 1 yes
yes_no 2 no

Thanks,
Abbas

Hi there,
A solution would be to create a new calculate question for which the
calculation would be if(${total_mem}=null,"yourDefaultValue",${total_mem})
(or, if you prefer, you can use string-length(${total_mem}) = 0) instead of
=null) that would compile both the cases where you have no answer (with
your default value) and those that do.
Best,
Maeve

··· Le samedi 21 mai 2016 20:11:30 UTC+1, abba...@gmail.com a écrit : > > Hi, > > In the survey sheet below you can see question with variable name > *"total_mem"* is skipped if *"totmem_check"=1. *The issue is if > "total_mem" is skipped, it leaves value of "total_mem" variable as empty ( > *default=0* option does not works if it is skipped). Is there any > way/option which would allow me to store value of total_mem=0 *if > question with variable name "total_mem" is skipped, otherwise store the > entered value (in case total_mem not skipped).* > > Why I want to do this? If "tot_mem" variable is empty then "new.mems" > variable won't calculate value (correctly). > > > *Survey Sheet* > type name label hint relevant calculation default > select_one yes_no totmem_check Total members are ${totmem}? (totmem) > is the total number of members of organization which we are pulling from > baseline > integer total_mem Total members in organization? ${totmem_check}=2 0 > calculate new.mems These are the number of new members in organization if(${total_mem}>${totmem},${total_mem} > - ${totmem},0) 0 > > choices sheet > list name name label > yes_no 1 yes > yes_no 2 no > > > Thanks, > Abbas > >

Thanks so much, Maeve.

··· On Sunday, May 22, 2016 at 8:23:30 PM UTC+5, ma...@de-france.net wrote: > > Hi there, > A solution would be to create a new calculate question for which the > calculation would be if(${total_mem}=null,"yourDefaultValue",${total_mem}) > (or, if you prefer, you can use string-length(${total_mem}) = 0) instead > of =null) that would compile both the cases where you have no answer > (with your default value) and those that do. > Best, > Maeve > > Le samedi 21 mai 2016 20:11:30 UTC+1, abba...@gmail.com a écrit : >> >> Hi, >> >> In the survey sheet below you can see question with variable name >> *"total_mem"* is skipped if *"totmem_check"=1. *The issue is if >> "total_mem" is skipped, it leaves value of "total_mem" variable as empty ( >> *default=0* option does not works if it is skipped). Is there any >> way/option which would allow me to store value of total_mem=0 *if >> question with variable name "total_mem" is skipped, otherwise store the >> entered value (in case total_mem not skipped).* >> >> Why I want to do this? If "tot_mem" variable is empty then "new.mems" >> variable won't calculate value (correctly). >> >> >> *Survey Sheet* >> type name label hint relevant calculation default >> select_one yes_no totmem_check Total members are ${totmem}? (totmem) >> is the total number of members of organization which we are pulling from >> baseline >> integer total_mem Total members in organization? ${totmem_check}=2 0 >> calculate new.mems These are the number of new members in organization >> if(${total_mem}>${totmem},${total_mem} - ${totmem},0) 0 >> >> choices sheet >> list name name label >> yes_no 1 yes >> yes_no 2 no >> >> >> Thanks, >> Abbas >> >>