If statement

Dear Friends,

I need help with a conditional statement. Under which column and how do I
write an if statement in xls form to change colour of answer of a
calculation. For example if my answer is les than 5 I want the result
should display in Green colour, if within 5-7 the colour should be yellow
and it within 7-10 it should be Red. You help will be highly appreciated.

Thanks,
Imran

Hi Imram,

Good question, and yes, this is possible.

I'd store the color using a calculate like this:
if((${answer} < 5), 'green', if((${answer} < 7), 'yellow', 'red'))

Instead of red/yellow/green, you can also use hex color codes like '#f58a1f'

Then build the resulting output like this:
concat('', ${answer}, '')

Then that resulting output can be put in any label or hint. I've
attached a sample form that does this.

Yaw

conditional_color.xlsx (10.4 KB)

ยทยทยท On Mon, Mar 27, 2017 at 5:01 PM, A.N.M AL-IMRAN wrote: > Dear Friends, > > I need help with a conditional statement. Under which column and how do I > write an if statement in xls form to change colour of answer of a > calculation. For example if my answer is les than 5 I want the result should > display in Green colour, if within 5-7 the colour should be yellow and it > within 7-10 it should be Red. You help will be highly appreciated. > > Thanks, > Imran > > -- > -- > 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.
2 Likes

Dear Yaw,

That's a life-saving help. It works perfectly on Collect. I didn't realize
that this set of code doesn't produce the desired result on Enketo
validator. I tried in so many different ways since I received your email
and at last realized it works perfectly on collect.

Thank you once again,
Imran

A N M AL IMRAN (Imran)
Brossard, QC
Canada
Cell: +1 (438) 501 3576

ยทยทยท On 1 April 2017 at 10:43, Yaw Anokwa wrote:

Hi Imram,

Good question, and yes, this is possible.

I'd store the color using a calculate like this:
if((${answer} < 5), 'green', if((${answer} < 7), 'yellow', 'red'))

Instead of red/yellow/green, you can also use hex color codes like
'#f58a1f'

Then build the resulting output like this:
concat('', ${answer}, '')

Then that resulting output can be put in any label or hint. I've
attached a sample form that does this.

Yaw

On Mon, Mar 27, 2017 at 5:01 PM, A.N.M AL-IMRAN imran3may@gmail.com wrote:

Dear Friends,

I need help with a conditional statement. Under which column and how do I
write an if statement in xls form to change colour of answer of a
calculation. For example if my answer is les than 5 I want the result
should
display in Green colour, if within 5-7 the colour should be yellow and it
within 7-10 it should be Red. You help will be highly appreciated.

Thanks,
Imran

--

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.

--

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/0rNxiVkIRX8/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.

1 Like

Imran: It'd be good to let Martijn know about this. Email him at
support@enketo.org.

Calum: Don't use if() for that. Instead, in the relevance column of
q3, put " ${q1} = 'no' and ${q2} = 'yes' ". More at
http://xlsform.org/#relevant.

ยทยทยท On Sat, Apr 1, 2017 at 4:27 PM, A.N.M AL-IMRAN wrote: > Dear Yaw, > > That's a life-saving help. It works perfectly on Collect. I didn't realize > that this set of code doesn't produce the desired result on Enketo > validator. I tried in so many different ways since I received your email and > at last realized it works perfectly on collect. > > Thank you once again, > Imran > > > A N M AL IMRAN (Imran) > Brossard, QC > Canada > Cell: +1 (438) 501 3576 > > On 1 April 2017 at 10:43, Yaw Anokwa wrote: >> >> Hi Imram, >> >> Good question, and yes, this is possible. >> >> I'd store the color using a calculate like this: >> if((${answer} < 5), 'green', if((${answer} < 7), 'yellow', 'red')) >> >> Instead of red/yellow/green, you can also use hex color codes like >> '#f58a1f' >> >> Then build the resulting output like this: >> concat('', ${answer}, '') >> >> Then that resulting output can be put in any label or hint. I've >> attached a sample form that does this. >> >> Yaw >> >> >> On Mon, Mar 27, 2017 at 5:01 PM, A.N.M AL-IMRAN wrote: >> > Dear Friends, >> > >> > I need help with a conditional statement. Under which column and how do >> > I >> > write an if statement in xls form to change colour of answer of a >> > calculation. For example if my answer is les than 5 I want the result >> > should >> > display in Green colour, if within 5-7 the colour should be yellow and >> > it >> > within 7-10 it should be Red. You help will be highly appreciated. >> > >> > Thanks, >> > Imran >> > >> > -- >> > -- >> > 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. >> >> -- >> -- >> 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/0rNxiVkIRX8/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. > > > -- > -- > 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.

Dear Yaw,

Thanks, I emailed to Martijn about this issue.

Regards,
Imran

A N M AL IMRAN (Imran)
Brossard, QC
Canada
Cell: +1 (438) 501 3576

ยทยทยท On 3 April 2017 at 15:56, Yaw Anokwa wrote:

Imran: It'd be good to let Martijn know about this. Email him at
support@enketo.org.

Calum: Don't use if() for that. Instead, in the relevance column of
q3, put " ${q1} = 'no' and ${q2} = 'yes' ". More at
http://xlsform.org/#relevant.

On Sat, Apr 1, 2017 at 4:27 PM, A.N.M AL-IMRAN imran3may@gmail.com wrote:

Dear Yaw,

That's a life-saving help. It works perfectly on Collect. I didn't
realize
that this set of code doesn't produce the desired result on Enketo
validator. I tried in so many different ways since I received your email
and
at last realized it works perfectly on collect.

Thank you once again,
Imran

A N M AL IMRAN (Imran)
Brossard, QC
Canada
Cell: +1 (438) 501 3576

On 1 April 2017 at 10:43, Yaw Anokwa yanokwa@nafundi.com wrote:

Hi Imram,

Good question, and yes, this is possible.

I'd store the color using a calculate like this:
if((${answer} < 5), 'green', if((${answer} < 7), 'yellow', 'red'))

Instead of red/yellow/green, you can also use hex color codes like
'#f58a1f'

Then build the resulting output like this:
concat('', ${answer}, '')

Then that resulting output can be put in any label or hint. I've
attached a sample form that does this.

Yaw

On Mon, Mar 27, 2017 at 5:01 PM, A.N.M AL-IMRAN imran3may@gmail.com wrote:

Dear Friends,

I need help with a conditional statement. Under which column and how
do

I
write an if statement in xls form to change colour of answer of a
calculation. For example if my answer is les than 5 I want the result
should
display in Green colour, if within 5-7 the colour should be yellow and
it
within 7-10 it should be Red. You help will be highly appreciated.

Thanks,
Imran

--

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.

--

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/0rNxiVkIRX8/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.

--

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.

--

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/0rNxiVkIRX8/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.

Hello. How can i can use if statement to filter out questions.

Like for example my first question is asking
Q1. Which project were you involve in?
1. Jilinde
2. Jiinue
3. Jielimishe

Q2. Which country was this project implemented

 1. Jilinde
   a. Country A
   b. Country B
   c. Country C
  1. Jiinue

a. Country A
b. Country D
c. Country E

  1. Jielimishe
    a. Country C
    b. Country D
    c. Country E

Now i want it to operate like a cascade but the some programs are shared among countries. How do i make it function such that if countries appear per project.

Thanks

Hi @smbai
looks as if you need cascading select http://xlsform.org/en/#cascading-selects not if statement.