Using a conditional statement in Survey123 to calculate two different equations based on choice of question.

5023
2
12-15-2016 03:24 PM
LorenceWilliams
New Contributor II

Hello,

I have a large survey whose questions display depending on the user's initial choice of a YES or NO question. If the user chooses YES, then the survey questions display and the total points from those questions the user fills out is added up in a total. If the user chooses NO the form calculates an automatic 55 pts.


Based on the sample statement provided in Survey 123's help:

if(selected(${question_one}, 'yes') and selected(${question_two}, 'yes'), 'yes', 'no')

Here is what I have so far, however I get an error each time I try to refresh the survey:

if(selected(${Fil_Srvy},’yes’) and selected (${Fil_Srvy}, ‘no’), ‘(${UTM_yes_no}-(-${MOBG_pts})-(-${Third_Party_BP})-(-${No_Third_Party_BP})-(-${Revenue_pts})-(-${Third_Party_WC})-(-${No_Third_Party_WC})-(-${Third_Party_Taxes})-(-${No_Third_Party_Taxes})-(-${Third_Party_BP_NoMtngs})-(-${No_Third_Party_BP_NoMtngs})), ‘55’)

So you see, what I am doing is asking it to add the particular fields in the total field if YES and if NO, then just display 55 points.

Thank you for all your suggestions and advice in advance.

Respectfully,

-Confused

Tags (3)
2 Replies
ShawnRoberts1
Occasional Contributor

HI Lawrence, I know this is a bit older of a question, but its very relevant to my current situation. Were you ever able to figure out a good solution?

Thanks,

Shawn

0 Kudos
LorenceWilliams
New Contributor II

We set the value of the hidden question to equal the value of the choice. Remember to use negative integers (each named filed has a minus sign before it except the first one) when adding.

Below is the formula we used as the grand total for all the selections. The most is 55 points the least is 0:

(${UTM_yes_no}-(-${MOBG_pts})-(-${Third_Party_BP})-(-${No_Third_Party_BP})-(-${Revenue_pts})-(-${Third_Party_WC})-(-${No_Third_Party_WC})-(-${Third_Party_Taxes})-(-${No_Third_Party_Taxes})-(-${Third_Party_BP_NoMtngs})-(-${No_Third_Party_BP_NoMtngs}))