# Nested if statements

Dear Lal_LAM,
I hope this finds you well.
Could you please help me with the below if statement:
if((\${high_risk}>=4),“4”, if((\${high_risk}=3 or \${medium_risk}>=11),“3”, if((\${high_risk}=2 or \${high_risk}=1 or \${medium_risk}<=10 and \${medium_risk}>0),“2”,“1”)))
It’s not correct I guess

Welcome back to the community, @khalid_amarkhail1! Would you mind sharing the dummy question for this so that we could understand your context better and help you out? Note, you need not share the entire question. You could share with us the two questions that should hold this expression.

kobo_nested_ifstatements.xlsx (9.7 KB)

Thanks!
Please check the file

@khalid_amarkhail1, the conditions are still unclear. Could you kindly provide details on your conditions …

##### Conditions:

high_risk: `4`
medium_risk: `>=11`
risk_cat: `4`

high_risk: `3`
medium_risk: `<=10`
risk_cat: `3`

Please try to be specific so that the community could help you with your query.

Hi,
Here is the revised syntax that I used and it worked:
if((\${high_risk}>=4),“4”, if((\${high_risk}=3 or \${medium_risk}>=11),“3”, if(((\${high_risk}=2 or \${high_risk}=1 or \${medium_risk}<=10) and \${medium_risk}>0),“2”,“1”)))

1. If high risk is>=4 so the calculated value should be 4.

2. If high risk =3 or medium risk>=1, then the calculated value should be 3

3. If high risk=2 or 1, or medium risk<=10 and >0, the calculated value should be 2

4. In case none of above conditions are met, the calculated value should be 1.

Please let me know if there is a better way or simplified version of the syntax that I can use.
Thanks

1 Like

Great @khalid_amarkhail1! Thank you for sharing this to the entire community!