Constraint Logic Errors

Hi all,

i know this is everyone's favorite topic! I am having some trouble with
writing the constraint for a previous select multiple question . Here is
what I have so far (the part in yellow is what doesn't work when I download
the form and try to implement the logic on the tablet). I appreciate your
help! Thank you!

Whitney

${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or (${oeildroit_actif}='4' and ${oeildroit_actif}='9'))

I also tried this, but it didn't work either:
${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or ((selected${oeildroit_actif}='4' and (selected${oeildroit_actif}='9'))))

I've attached the Excel file, in case that is also helpful.

A huge thanks in advance,

Whitney

Constraints involving values of select-multiple questions always require
the use of the selected(field,value) function.

so if you wanted to test if ${oeildroit_actif} has the value '4', you would
write:

selected(${oeildroit_actif},'4')

This returns true if '4' is among the choices selected, and false otherwise.

Note that the choice names are string values (i.e., the string '4', not the
number 4) and that the set of selected names are stored as a
space-separated sequence of names. Because of this, choice names should
never contain spaces.

··· On Thu, Mar 12, 2015 at 1:07 PM, Whitney wrote:

Hi all,

i know this is everyone's favorite topic! I am having some trouble with
writing the constraint for a previous select multiple question . Here is
what I have so far (the part in yellow is what doesn't work when I download
the form and try to implement the logic on the tablet). I appreciate your
help! Thank you!

Whitney

${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or (${oeildroit_actif}='4' and ${oeildroit_actif}='9'))

I also tried this, but it didn't work either:
${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or ((selected${oeildroit_actif}='4' and
(selected${oeildroit_actif}='9'))))

I've attached the Excel file, in case that is also helpful.

A huge thanks in advance,

Whitney

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Hi Mitch,

Thanks for your reply, but I think I am a bit lost.

For the constraint I want to write, there is a multiple select option as a
first question (please check all of the appropriate disease signs). The
name of the choices are: 1, 2, 3, 4, 9 and 99.

For the following question, it is only relevant if the previous answer is:
either '3' (by itself), '4' (by itself), or '9' (by itself), or if both
'4' and '9' are chosen together.

Everything worked well, except for if '4' and '9' are chosen together. I
can't seem to write the constraint in such a way that the following
question appears if these two are selected together using this constraint:

${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or (${oeildroit_actif}='4' and ${oeildroit_actif}='9'))

I've re-written the constraint according to how I think I understand your
message. It now looks like this:

(${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1') and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or ((selected(${oeildroit_actif}='4')) and
(selected(${oeildroit_actif}='9'))))

It uploads to the tablet fine, but when I try and advance through the
questionnaire, this error message shows on the screen of the tablet:

[image: Displaying Screenshot_2015-03-14-12-08-55.png]

Any help would be greatly appreciated. Thank you!

··· On Friday, March 13, 2015 at 1:44:46 PM UTC-4, Mitch Sundt wrote: > > Constraints involving values of select-multiple questions always require > the use of the *selected(field,value)* function. > > so if you wanted to test if ${oeildroit_actif} has the value '4', you > would write: > > selected(${oeildroit_actif},'4') > > This returns true if '4' is among the choices selected, and false > otherwise. > > Note that the choice names are string values (i.e., the string '4', not > the number 4) and that the set of selected names are stored as a > space-separated sequence of names. Because of this, choice names should > never contain spaces. > > > > On Thu, Mar 12, 2015 at 1:07 PM, Whitney <whitney...@gmail.com > wrote: > >> Hi all, >> >> i know this is everyone's favorite topic! I am having some trouble with >> writing the constraint for a previous select multiple question . Here is >> what I have so far (the part in yellow is what doesn't work when I download >> the form and try to implement the logic on the tablet). I appreciate your >> help! Thank you! >> >> Whitney >> >> ${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and >> (${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4' >> or (${oeildroit_actif}='4' and ${oeildroit_actif}='9')) >> >> I also tried this, but it didn't work either: >> ${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and >> (${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4' >> or ((selected${oeildroit_actif}='4' and >> (selected${oeildroit_actif}='9')))) >> >> >> I've attached the Excel file, in case that is also helpful. >> >> >> A huge thanks in advance, >> >> Whitney >> >> -- >> -- >> Post: opend...@googlegroups.com >> Unsubscribe: opendatakit...@googlegroups.com >> Options: http://groups.google.com/group/opendatakit?hl=en >> >> --- >> You received this message because you are subscribed to the Google Groups >> "ODK Community" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to opendatakit...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Mitch Sundt > Software Engineer > University of Washington > mitche...@gmail.com >

I wrote:

selected(${oeildroit_actif},'4')

not:

selected(${oeildroit_actif}='4')

Your formulas are incorrect. If you are using the XLSForm executable, you
should also use ODK Validate (
https://opendatakit.org/downloads/download-info/odk-validate-2/ ) to verify
the correctness of the form (this is automatically done when using the
web-based XLSForm tool). This would have reported an error with your form.

The function, selected(X,Y), returns true if the field X had the value Y
chosen among its multiple-choice selections. It returns false otherwise.

There is no '='

Use this function for all tests of the values of all multiple-choice
questions
.

Using '=' for those tests will fail if two or more choices are selected.

i.e.,

${oeildroit_actif} = '1' or ${oeildroit_actif} = '2'

will fail if you were to select both 1 and 2.

But

selected(${oeildroit_actif},'1') or selected(${oeildroit_actif}, '2')

will work if you select either 1 or 2 or 1 and 2 together (or along with
any other options in the multiple-choice question).

··· On Sat, Mar 14, 2015 at 5:17 AM, Whitney wrote:

Hi Mitch,

Thanks for your reply, but I think I am a bit lost.

For the constraint I want to write, there is a multiple select option as a
first question (please check all of the appropriate disease signs). The
name of the choices are: 1, 2, 3, 4, 9 and 99.

For the following question, it is only relevant if the previous answer is:
either '3' (by itself), '4' (by itself), or '9' (by itself), or if both
'4' and '9' are chosen together.

Everything worked well, except for if '4' and '9' are chosen together. I
can't seem to write the constraint in such a way that the following
question appears if these two are selected together using this constraint:

${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or (${oeildroit_actif}='4' and ${oeildroit_actif}='9'))

I've re-written the constraint according to how I think I understand your
message. It now looks like this:

(${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1') and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or ((selected(${oeildroit_actif}='4')) and
(selected(${oeildroit_actif}='9'))))

It uploads to the tablet fine, but when I try and advance through the
questionnaire, this error message shows on the screen of the tablet:

[image: Displaying Screenshot_2015-03-14-12-08-55.png]

Any help would be greatly appreciated. Thank you!

On Friday, March 13, 2015 at 1:44:46 PM UTC-4, Mitch Sundt wrote:

Constraints involving values of select-multiple questions always require
the use of the selected(field,value) function.

so if you wanted to test if ${oeildroit_actif} has the value '4', you
would write:

selected(${oeildroit_actif},'4')

This returns true if '4' is among the choices selected, and false
otherwise.

Note that the choice names are string values (i.e., the string '4', not
the number 4) and that the set of selected names are stored as a
space-separated sequence of names. Because of this, choice names should
never contain spaces.

On Thu, Mar 12, 2015 at 1:07 PM, Whitney whitney...@gmail.com wrote:

Hi all,

i know this is everyone's favorite topic! I am having some trouble with
writing the constraint for a previous select multiple question . Here is
what I have so far (the part in yellow is what doesn't work when I download
the form and try to implement the logic on the tablet). I appreciate your
help! Thank you!

Whitney

${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or (${oeildroit_actif}='4' and ${oeildroit_actif}='9'))

I also tried this, but it didn't work either:
${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or ((selected${oeildroit_actif}='4' and (selected${oeildroit_actif}='
9'))))

I've attached the Excel file, in case that is also helpful.

A huge thanks in advance,

Whitney

--

Post: opend...@googlegroups.com
Unsubscribe: opendatakit...@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google
Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitche...@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Thanks, Mitch. I had overlooked the "=" in the previous formula.

Thank you very much for the explanation and the ODK Validate link.
Everything seems to be working well now, so I really appreciate your help.

Thanks again,

Whitney

··· On Sat, Mar 14, 2015 at 12:32 PM, Mitch Sundt wrote:

I wrote:

selected(${oeildroit_actif},'4')

not:

selected(${oeildroit_actif}='4')

Your formulas are incorrect. If you are using the XLSForm executable, you
should also use ODK Validate (
https://opendatakit.org/downloads/download-info/odk-validate-2/ ) to
verify the correctness of the form (this is automatically done when using
the web-based XLSForm tool). This would have reported an error with your
form.

The function, selected(X,Y), returns true if the field X had the value Y
chosen among its multiple-choice selections. It returns false otherwise.

There is no '='

Use this function for all tests of the values of all multiple-choice
questions
.

Using '=' for those tests will fail if two or more choices are selected.

i.e.,

${oeildroit_actif} = '1' or ${oeildroit_actif} = '2'

will fail if you were to select both 1 and 2.

But

selected(${oeildroit_actif},'1') or selected(${oeildroit_actif}, '2')

will work if you select either 1 or 2 or 1 and 2 together (or along with
any other options in the multiple-choice question).

On Sat, Mar 14, 2015 at 5:17 AM, Whitney whitney.goldman@gmail.com wrote:

Hi Mitch,

Thanks for your reply, but I think I am a bit lost.

For the constraint I want to write, there is a multiple select option as
a first question (please check all of the appropriate disease signs). The
name of the choices are: 1, 2, 3, 4, 9 and 99.

For the following question, it is only relevant if the previous answer
is: either '3' (by itself), '4' (by itself), or '9' (by itself), or if
both '4' and '9' are chosen together.

Everything worked well, except for if '4' and '9' are chosen together. I
can't seem to write the constraint in such a way that the following
question appears if these two are selected together using this constraint:

${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or (${oeildroit_actif}='4' and ${oeildroit_actif}='9'))

I've re-written the constraint according to how I think I understand your
message. It now looks like this:

(${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1') and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or ((selected(${oeildroit_actif}='4')) and
(selected(${oeildroit_actif}='9'))))

It uploads to the tablet fine, but when I try and advance through the
questionnaire, this error message shows on the screen of the tablet:

[image: Displaying Screenshot_2015-03-14-12-08-55.png]

Any help would be greatly appreciated. Thank you!

On Friday, March 13, 2015 at 1:44:46 PM UTC-4, Mitch Sundt wrote:

Constraints involving values of select-multiple questions always require
the use of the selected(field,value) function.

so if you wanted to test if ${oeildroit_actif} has the value '4', you
would write:

selected(${oeildroit_actif},'4')

This returns true if '4' is among the choices selected, and false
otherwise.

Note that the choice names are string values (i.e., the string '4', not
the number 4) and that the set of selected names are stored as a
space-separated sequence of names. Because of this, choice names should
never contain spaces.

On Thu, Mar 12, 2015 at 1:07 PM, Whitney whitney...@gmail.com wrote:

Hi all,

i know this is everyone's favorite topic! I am having some trouble
with writing the constraint for a previous select multiple question . Here
is what I have so far (the part in yellow is what doesn't work when I
download the form and try to implement the logic on the tablet). I
appreciate your help! Thank you!

Whitney

${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or (${oeildroit_actif}='4' and ${oeildroit_actif}='9'))

I also tried this, but it didn't work either:
${hhconsnt}='1' and ${presence}='Present' and ${TRA_SIGN}='1' and
(${oeildroit_actif}='3' or ${oeildroit_actif}='9' or ${oeildroit_actif}='4'
or ((selected${oeildroit_actif}='4' and (selected${oeildroit_actif}='
9'))))

I've attached the Excel file, in case that is also helpful.

A huge thanks in advance,

Whitney

--

Post: opend...@googlegroups.com
Unsubscribe: opendatakit...@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google
Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitche...@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit/gAqdLvZI62U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Whitney Goldman, MPH
(843) 694-7485
whitney.goldman@gmail.com
Skype: whitney.goldman

Hi Mitch,

I just found this post and have a similar problem that so far am unable to solve.

I want to create a constraint on a select_one question ${select_now}, the constraint is meant to avoid the respondent selecting the same value in ${select_now} and the previous select_one question ${select_previous}.

I have used tried to apply the following constraint on ${select_now}:

selected(${select_previous}='public' and ${select_now}='public') or selected(${select_previous}='business' and ${select_now}='business') or selected(${select_previous}='gov' and ${select_now}='gov') or selected(${select_previous}='ngo' and ${select_now}='ngo')

This constraint doesn't allow the the respondent to select any of the options in ${select_now}.

Could you please let me know what I am doing wrong?

Thank you!

Try with:

selected(${select_previous}, 'public') and selected(${select_now}, 'public')

Instead of:

selected(${select_previous}='public' and ${select_now}='public')

··· El viernes, 14 de octubre de 2016, 13:46:25 (UTC-5), henri....@gmail.com escribió: > > Hi Mitch, > > I just found this post and have a similar problem that so far am unable to > solve. > > I want to create a constraint on a select_one question ${select_now}, the > constraint is meant to avoid the respondent selecting the same value in > ${select_now} and the previous select_one question ${select_previous}. > > I have used tried to apply the following constraint on ${select_now}: > > selected(${select_previous}='public' and ${select_now}='public') or > selected(${select_previous}='business' and ${select_now}='business') or > selected(${select_previous}='gov' and ${select_now}='gov') or > selected(${select_previous}='ngo' and ${select_now}='ngo') > > This constraint doesn't allow the the respondent to select any of the > options in ${select_now}. > > Could you please let me know what I am doing wrong? > > Thank you! > > >

Thank you Jorge!

··· Sent from my iPhone

On 15 Oct 2016, at 05:52, Jorge Ruiz Cabrejos jruizcabrejos@gmail.com wrote:

Try with:

selected(${select_previous}, 'public') and selected(${select_now}, 'public')

Instead of:

selected(${select_previous}='public' and ${select_now}='public')

El viernes, 14 de octubre de 2016, 13:46:25 (UTC-5), henri....@gmail.com escribió:

Hi Mitch,

I just found this post and have a similar problem that so far am unable to solve.

I want to create a constraint on a select_one question ${select_now}, the constraint is meant to avoid the respondent selecting the same value in ${select_now} and the previous select_one question ${select_previous}.

I have used tried to apply the following constraint on ${select_now}:

selected(${select_previous}='public' and ${select_now}='public') or selected(${select_previous}='business' and ${select_now}='business') or selected(${select_previous}='gov' and ${select_now}='gov') or selected(${select_previous}='ngo' and ${select_now}='ngo')

This constraint doesn't allow the the respondent to select any of the options in ${select_now}.

Could you please let me know what I am doing wrong?

Thank you!