Select to view content in your preferred language

How to create a nested "if" statement for calculating a value

614
1
Jump to solution
06-08-2022 11:34 AM
JoseBarrios1
Occasional Contributor III

Hello everyone,

I am stuck on creating a nested “if” statement for survey123 calculation. Here is my workflow: I have a “select multiple” question and I want to  capture on a separate field  a integer value depending on the selection (see attached pic). For example, selecting A, B or C will get a value of 1; selecting D or E will get a value of 2’ and F a value of 3. The problem is that I don’t know how to set-up the condition to assign 2 when D or E are selected even if any of the ABC are also selected, or value of 3 if F is selected and any of the other values are also selected.  Thanks for any suggestion on how to accomplish this!

JBvalues.png

0 Kudos
1 Solution

Accepted Solutions
JoseBarrios1
Occasional Contributor III

I think I figured it out!. Here is the "if" nested statement that I created just in case anyone have the same need! I had to set the statement on reverse to work!

if(selected(${lettertype},'F'),3, if(selected(${letterwtype},'E') or selected(${lettertype},'D’),2, if(selected(${lettertype},'C') or selected(${lettertype},'B') or selected(${lettertype},'A'),1,"0")))

Thanks,

JB

View solution in original post

0 Kudos
1 Reply
JoseBarrios1
Occasional Contributor III

I think I figured it out!. Here is the "if" nested statement that I created just in case anyone have the same need! I had to set the statement on reverse to work!

if(selected(${lettertype},'F'),3, if(selected(${letterwtype},'E') or selected(${lettertype},'D’),2, if(selected(${lettertype},'C') or selected(${lettertype},'B') or selected(${lettertype},'A'),1,"0")))

Thanks,

JB

0 Kudos