I have a select_one question with 6 values for bolt sizes, I want to populate a note after that question with the correct torque value from a table based on the bolt size. I assume that I need an if statement in the calculation filed but I can't figure out the formatting of the statement.
Bolt Size | Torque |
---|---|
.5 | 17 |
.625 | 50 |
.75 | 75 |
.875 | 83 |
1 | 125 |
1.125 | 212 |
Solved! Go to Solution.
Hi Andrew,
There are a few of things at issue. The first is that the selected() function requires 2 parameters - the question to check and teh value to check (it doesn't need the = sign in the formula). The second is that, based on your parenthesis, the if statement had only 1 parameter, not 3. Finally, the value you are checking is specified as '.5'; you should check for '0.5' (these aren't the same when treating the values as text, which is how select_one questions are stored).
if(selected(${BoltSize}, '0.5'),'17', 'other')
should get you started - in the place of 'other', you would proceed to have a nested series of if() statements to select the proper value.
It might be a little simpler to treat this as a data table and use pulldata() to look up the values instead.
Hi Andrew,
There are a few of things at issue. The first is that the selected() function requires 2 parameters - the question to check and teh value to check (it doesn't need the = sign in the formula). The second is that, based on your parenthesis, the if statement had only 1 parameter, not 3. Finally, the value you are checking is specified as '.5'; you should check for '0.5' (these aren't the same when treating the values as text, which is how select_one questions are stored).
if(selected(${BoltSize}, '0.5'),'17', 'other')
should get you started - in the place of 'other', you would proceed to have a nested series of if() statements to select the proper value.
It might be a little simpler to treat this as a data table and use pulldata() to look up the values instead.
Thanks James, using pulldata() was a better solution for this.