Formula for Complex Constraint

Hello…
Sorry for asking so many questions.
maybe someone can help me…
I have three select one question type that automatically fill in. There are

  1. {E1_BPJS_SC0E01} “Respondent have National health insurance” with choice 0(No); 1(Yes). It will be filled in automatically “1(yes)” if ${C1_BPJS_SC} = 1 or ${C2_KIS_SC} = 1 and “0(No)” if ${C1_BPJS_SC} = 0 and ${C2_KIS_SC} = 0.
    {C2_KIS_SC} will be asked if {C1_BPJS_SC}=0.

2.{E7_PTL_SC} “Does the respondent have a plan to live in the same area for the next 16 months? (September 2019 – Desember 2020)?” with choice 1{No};2{Yes}. It will be filled in automatically “1(Yes)” if ${A14_RPTL_SC} = 2 0r 3 or 88 and “0(No)” if ${A14_RPTL_SC} = 1.

  1. {F1_HI_SC} “Respondent has undergone surgery to implant foreign subjects to the body?” with choice 0(No) and 1{Yes}.It will be filled in automatically “1(Yes)” if ${C3_HOS_SC} = 1 and {C4_HOIP_SC}=1 and “0(No)” if ${C3_HOS_SC} = 0 or ${C3_HOS_SC} = 1 and {C4_HOIP_SC}=0.

{C4_HOIP_SC} will be asked if {C3_HOS_SC}=1.

I already made a formula in the compute column and constraints coloumn but it didn’t work.

try2.xls (39 KB)

Hi,
I have looked at your form. and you may have added elements you did not need on the constraints. I have however changed your form and this should be working well now as per attached documentation try2.xls (38.5 KB) . Please feel free to amend using the same logic I applied in the calculate.

Hope this sorts you out
Stephane

1 Like

stephanealoo thank you it’s work…

but I still can change the data,
how to do it if the data that is automatically filled can be frozen or cannot be replaced?

Hello @dy10,
you may use read_only column (attribute) in the survey tab, see https://xlsform.org/en/#read-only
Or you could use a calculate type.

Side-note:

  1. You can use one single Yes/No choice list, instead of your duplicates.
  2. Why do you use select_one if user cannot change, instead of calculate type (plus note, if needed to show)?
  3. Why not do such calculation later during analysis, outside KoBo?

Kind regards

1 Like