Calculation syntax to return specific value for a select_one question, dependent on a text question

960
2
Jump to solution
04-20-2021 08:39 PM
JulietK
Occasional Contributor II

Hi, I am struggling with the below- 

I'm wanting a specific value to pop up as default, if a previous text question is answered with a specific text.  

For example:

JulietK_0-1618976042515.png

JulietK_1-1618976103946.png

I would like 'Manufacture Company' to field to return the 'nocompany' selection option automatically (without the survey user having to manually select this option), if the value 'NO ITEM ASSOCIATED' is entered into the text field 'Item Code', but otherwise leave blank (for the user to manually select). 

So far the syntax examples I've found have been only for return value depending on value from a select_one/select_multiple question, or only for integer-related entries. 

Any advice would be greatly appreciated! 

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi @JulietK,

This is possible using an if() statement in the calculation column of the select one. For example, based on your screenshot above:

if(${code}='NO ITEM ASSOCIATED','nocompany','')

This will select the nocompany choice when the exact string in the text field equals NO ITEM ASSOCIATED, but if the string is anything else, the calculation will set the value as null, so then the user can choose any value from the dropdown. Is this what you are after?

Regards,

Phil.

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable

Hi @JulietK,

This is possible using an if() statement in the calculation column of the select one. For example, based on your screenshot above:

if(${code}='NO ITEM ASSOCIATED','nocompany','')

This will select the nocompany choice when the exact string in the text field equals NO ITEM ASSOCIATED, but if the string is anything else, the calculation will set the value as null, so then the user can choose any value from the dropdown. Is this what you are after?

Regards,

Phil.

0 Kudos
JulietK
Occasional Contributor II

Hi Philip, 

Perfect, thank you so much! Looks like I've been missing the apostrophes in the last section of the syntax 🙂