Dear Colleagues,

I need your support (A sample of XForms) with (IF, Or, AND) functions. I found some examples here, but could not understood.

Thanks

Rahmat

Dear Colleagues,

I need your support (A sample of XForms) with (IF, Or, AND) functions. I found some examples here, but could not understood.

Thanks

Rahmat

Hi @rahmat,

You should be able to find a couple of examples on our support article **Advanced Use of Calculate Questions**.

Have a great day!

Dear Kal_Lam,

Thank you for that. Actually, I already checked all these formulas. Can you help me use the below excel functions in Kobo (How should I write there in XForms)

=IF(OR(Q3]=âPoorâ,[Q3]]=âBorderlineâ,),3,0)

=IF(OR(AND(Q1=âHigh copingâ, Q2=âPoorâ), AND(Q1=âMedium copingâ, Q2=âPoorâ), AND(Q1=âHigh copingâ, Q2=âBorderlineâ)), âSeverely food insecureâ, IF(OR(AND(Q1=âLow copingâ, Q2=âPoorâ), AND(Q1=âMedium copingâ, Q2=âBorderlineâ), AND(Q1=âHigh copingâ, Q2=âAcceptableâ)), âModerately food insecureâ, âFood secureâ)))

In those examples you posted, mentioned that we cannot use IF, OR, AND together. What will be the alternative?

Best

Hi @rahmat,

Could you provide me some conditions (maybe with a demo question and options) so that i could help you out. Alternatively you could also have a look at some of our workaround that has been discussed earlier **here**.

Have a great day!

Hi @rahmat,

The file you shared does not help me. I would appreciate if you could list out some conditions along with a dummy question and options so that we could help you out as how it looks in the xlsform.

Have a great day!

Dear @Kal_Lam

Before, I share the question and conditions, can you give me an example of below statements used in a calculation in XLSForm? I may be able to figer out.

If statement used ALONE

IF and OR statements used in a calculation

IF, OR, AND statements used together in a calculation.

thanks

rahmat

Hi @rahmat,

**Here** are some workarounds that has been discussed in the community previously. Would you mind checking them out. It should solve your issue.

Have a great day!

Hi @rahmat,

The `if condition`

is already there in the xlsform. Have you checked it out?

Have a great day!

Yes but it is not giving the result I want.

Hi @rahmat,

So please try to being specific on what you wish to see or have. That would only be the way-out for your solution. We thus need a small description of what you require so that we would be able to support.

Have a great day!

Hi team, I understand his question correctly. @rahmat wanted to use that formula a indicator of food security.

This is the formula in excel =IF(G7<=28,âFaibleâ,IF(AND(G7>28,G7<=42),âLimiteâ,âAcceptableâ))

That formula will be apply on a calculated field in kobo to make a decision of the status of householder regarding their score.

Hi

I need to know what exactly are the conditions you need for me to be able to execute this.

Also confirm if this worked for you

Stephane

1 Like

Dear @stephanealoo

As in excel we have several functions/formulas such as IF, OR, AND.

I want to apply the same formulas in Kobo and when collecting data, at the end of the form, the data collectors will know whether the interviewee is eligible for assistance or Not. Thus, I want to use a formula like:

=IF(OR(BH2=âPoorâ,BH2=âBorderlineâ,),3,0)

In conclusion, once the form is completed in KoboCollect, the data collector will enderstand, whether the interviewee is eligible or not. We have several other functions but once we solve this one, we can applly others ourselves.

Best

Rahmat

I believe you are familiar with writing complex calculations as explained in our article here

However for specifics about the question you are asking

You can use double if to execute the OR functionality. i.e.

**=if(${BH2}=âPoorâ,3,(if(${BH2}=âBorderlineâ,3,0)))**

or

You can use

**=if((${BH2}=âPoorâ or ${BH2}=âBorderlineâ),3,0)**

Stephane

1 Like

Thank you very much @stephanealoo

Can you also give an example for below function as there we have IF, AND, OR together?

=IF(OR(AND(AT4=âLowâ, AM4=âPoorâ), AND(AT4=âMediumâ, AM4=âBorderlineâ), AND(AT4=âHighâ, AM4=âAcceptableâ)), âModeratelyâ, âFoodâ)))

Rahmat

Try this

**=if(((${AT4}=âLowâ and ${AM4}=âPoorâ) or (${AT4}=âMediumâ and ${AM4}=âBorderlineâ) or (${AT4}=âHighâ and ${AM4}=âAcceptableâ)), âModeratelyâ, âFoodâ)**

Thank you very much. will definately try this and update you accordingly. Once these things work, I will prepare a good excel file with all these formulas in excel and Kobo and upload here for other friends

Hi,

This one =if(${BH2}=âPoorâ,3,(if(${BH2}=âBorderlineâ,3,0))) WORKED

2 Likes