Hi, Tony.
Try this (assuming that your Q2 is select_one question):
put the following expression
( .='a' and ${Q1_name}<10 ) OR ( .='b' and ${Q1_name}>=10 and
${Q1_name}<=20 ) OR ( .='c' and ${Q1_name}>20 )
in the constraint column of Q2
Note that in this expression, "." is put for ${Q2_name}.
Hope that helps.
Best,
as i user of ODK, i am asking one thing about your question and answer of Amal. May i know please which element has been used for the syntax as Amal replied. I used "selected" but it didn't work...
I am having a problem like this: I want to put a constraint between an
integer input and a choice in multiple choice question.
q1. How much do you spend on food everyday? _________
q2. Please select the range ?
Less than 10usd
Between 10usd and 20usd
More than 20usd
I want to put a constraint that warn the surveyors in case they input 50usd
and select 1 or 2. Is there anyway to do that.
I just copied that I faced the similar case and I follow as given instruction using the xls syntax “(q2='1' and ${q1}<10 ) or (q2='2' and ${q1}>=10 and q2=2 and ${q1}<=20) or ( q2='3' and ${q1}>20)” BUT I could not get success so could you please help me to make right syntax…
Hi @debu_odk
I think it should be (selected(., 'q2a') and /data/q1 < 10) or (selected(., 'q2b') and /data/q1 > 10 and /data/q1 < 20) or (selected(., 'q2c') and /data/q1 > 20)
look at the xls file and the form: test.xml (1.4 KB) test.xlsx (7.6 KB)
Thank you very much for assisting me on the matter unfortunately it didn't work what i expecting when i tested and tried uploading. I got the results which i have attached...but i am not much aware about xml codes... I hope you can develope new syntax for it.
It works well if you use this form in Collect app I don't know why it doesn't work in Enketo preview and I'cant help because I am focused only on ODK Collect. Do you want to use this form in Collect or Enketo?