Using IF conditional and OR

Hi everyone
I´m new in this community, I´m glad to be here. I have a question. I´ve been trying to run this logical function in a Kobo Form but I cant do it
Function:
SI(Y(medical_condition=“No”,disabilities=“No”),SUM(age,sex),SI(medical_condiction=“Yes”,”Medical conditions exist”,SI(disabilities=“yes”,”disability exists”,0)))
I want to SUM ages and sex values only when there´s not exit a medical condition or disability. And IF already exists some of last those then only count their value-

age: 18 0 25 (6 points) / 26 a 59 (10 points)
Medical condition: Yes/No
Disabilities: Yes/No

Welcome to the community, @KatherineMelendez! Maybe you will need to share your question, its conditions, and its value with the community. You may also need to share what you expect as an output.

Hi @Kal_Lam

i am facing the same issue , just wanted to know that does Kobo handle the multple if conditions along with “And” IN Constraint column

below is the constraint i used in form

IF((${ptpvisit2day} = ‘11’ and ${Amount_Collected_Today}>0),(.>today() and .<today()+28),IF((A${ptpvisit2day} = ‘22’),(.>today() and .<today()+5),(.>today() and .<today()+15)))

the later two conditions are giving perfect results but the first condition “((${ptpvisit2day} = ‘11’ and ${Amount_Collected_Today}>0),” is not working

please guide if any error in this “and” condition , or if i am missing something

Please guide

Cheers !

Neeraj

Welcom @caneeraj ,
As KoBo/ODK key words in general, IF must be written with small letters: if.

1 Like

Hi, Kal_Lam. Thanks for your answer

La pregunta va mas enfocada a si se puede hacer de la siguiente manera:
if (${Discapacidad_cal1} = 0, ${Age0}+${Age1}+${Age2}+${Age3}+${Age4}, 5 and if (${Atencion_Salud_cal1} = 0, ${Age0}+${Age1}+${Age2}+${Age3}+${Age4},7)

Maybe this is what you are trying to do if it’s mutually exclusive (in-case of mutually inclusive, it could be an issue though) …

if(${Disability_cal1}='0', (${Age0}+${Age1}+${Age2}+${Age3}+${Age4}),'5') or if(${Health_Care_cal1} = '0', (${Age0}+${Age1}+${Age2}+${Age3}+${Age4}),'7')

Hi @wroos

tries with if also but not succeed

if ((${ptpvisit2day} = ‘11’ and ${Amount_Collected_Today}>0),(.>today() and .<today()+28),IF((A${ptpvisit2day} = ‘22’),(.>today() and .<today()+5),(.>today() and .<today()+15)))

the later two conditions are giving perfect results but the first condition “((${ptpvisit2day} = ‘11’ and ${Amount_Collected_Today}>0),” is not working

please guide if any error in this “and” condition , or if i am missing something

There is still one capital IF in your copy.
Did you check your form with the Online validator? (Always recommended during form development) Open Data Kit - XLSForm Online

For testing, you could temporarily reduce your if condition to the first part, which is not working and try to better locate/understand the problem. You may also put ( today()+28 ) in brackets. And test this calculation in an extra (text) variable.

1 Like

Hi, I thinks is inclusive.


For example, if seleled the option {Lengua_Materna} != ‘espanol’ , 12, 0
just add 12 excluding Age (see Imagen)

Gracias!

Hello @KatherineMelendez,
side-note. An age of 26 is not covered by the ranges in your age calculations. This will always result in a calculated value of 0.

1 Like

Hi @wroos

Still not working , Please help
out of the below

if ((${ptpvisit2day} = ‘11’ and ${Amount_Collected_Today} !=" “),(.>today() and .<today()+28),if((${ptpvisit2day} = ‘22’),(.>today() and .<today()+5),if((${ptpvisit2day} = ‘11’ and ${Amount_Collected_Today} =” "),(.>today() and .<today()+15),(.>today() and .<today()+5))))

the below condition is not working

,if((${ptpvisit2day} = ‘11’ and ${Amount_Collected_Today} =" "),(.>today() and .<today()+15)

Please help

HI @wroos @Kal_Lam

its done

if((${ptpvisit2day} = ‘11’ and ${odrecdtoday} = ‘yes’ and ${Amount_Collected_Today} >500),(.>today() and .<today()+28),if((${ptpvisit2day} = ‘11’ and ${odrecdtoday} = ‘no’),(.>today() and .<today()+14),if((${ptpvisit2day} = ‘22’ and ${odrecdtoday} = ‘yes’ and ${Amount_Collected_Today} >500),(.>today() and .<today()+28),(.>today() and .<today()+5))))

Thanks a lot everyone

1 Like

Hello @caneeraj,
so, it was only a problem of the logic, but not of KoBo? Could you confirm, please?

1 Like

Hi @wroos

Indeed it was a logic’s problem

1 Like

@caneeraj, :clap: :heart: :partying_face: