# Survey123 Calculation - Multiple If Parameters

1966
5
03-22-2021 04:35 PM by
New Contributor III

Hi,

I was wondering how to deal with multiple if conditions in a Survey123 calculation.  I know you can embed an if within in if but I'm not sure if this can handle all the if circumstances.  Basically, in my case, depending on which region you pick from a Select One list, a different formula will be used to crunch the same value parameter.  I have four different formulas, and one of them has two if's within it, so a total of five possible formulas used to crunch the same parameter.

How could I structure this?

Tags (2)
1 Solution

Accepted Solutions by Esri Regular Contributor

Hi @dgray it sounds like you want to nest five if() statements in one expression, is that right? That's definitely doable. As demonstrated in this reply, you can nest multiple if() statements, remembering to ensure each if() contains three arguments. The following example tests five conditions:

if(condition, value if true, if(condition, value if true, if(condition, value if true, if(condition, value if true, if(condition, value if true, value if false)))))

It's often easier to construct each if() statement separately first and check that each one works, before merging them into one expression.

Hope this helps. Best, Jim

5 Replies by Esri Regular Contributor

Hi @dgray it sounds like you want to nest five if() statements in one expression, is that right? That's definitely doable. As demonstrated in this reply, you can nest multiple if() statements, remembering to ensure each if() contains three arguments. The following example tests five conditions:

if(condition, value if true, if(condition, value if true, if(condition, value if true, if(condition, value if true, if(condition, value if true, value if false)))))

It's often easier to construct each if() statement separately first and check that each one works, before merging them into one expression.

Hope this helps. Best, Jim Occasional Contributor II

How would you deal with dates?  If there is a date selected/entered....if there isn't a date selected/entered.

If there is a date entered in field A, I want field B to be "Completed".  If there isn't a date entered in field A, I want field B to be "Open"? by MVP Honored Contributor

if(\${datefield} = "", "Open", "Completed") by MVP Honored Contributor

The other way is to have 4 calculate fields that always do all 4 calcs.  Then use the if to pick out which one to use.  Easier to write.

If say the multiplier changes then I use pulldata for that.  I do a lookup to get the value then use that to say multiply.

Hope that helps by
New Contributor III

Great, both are useful pieces of information.  Thanks! 