Survey123 Calculation - Multiple If Parameters

3457
5
Jump to solution
03-22-2021 04:35 PM
dgray
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
Jim-Moore
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

View solution in original post

5 Replies
Jim-Moore
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

KellyArmstrong
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"?

 

DougBrowning
MVP Esteemed Contributor

if(${datefield} = "", "Open", "Completed")

DougBrowning
MVP Esteemed 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

 

dgray
by
New Contributor III

Great, both are useful pieces of information.  Thanks!

0 Kudos