If(selected... is returning 'true', rather than the term specified in the formula

280
2
Jump to solution
03-15-2021 03:38 PM
JulietK
Occasional Contributor

Hi, I am trying to get a field to return specified terms depending on the selections in another field. 

For example:

Field 'Bird' is a select_one field, and choices are 'Sparrow', 'Pigeon', 'Hawk', 'Duck', 'Eagle'

Field 'Category' is a calculate field, and I would like the field to return the value 'Predator' if 'Hawk' or 'Eagle' are selected in the 'Bird' field, and 'Prey' if neither are selected.

The formula I have is: 

if(selected(${Bird},'Hawk'),'Predator','Prey') OR if(selected(${Bird},'Eagle'),'Predator','Prey')

The issue is, the value turning up in the output of the field 'Category' is 'true', REGARDLESS of what is selected in the 'Bird' field.

JulietK_0-1615847859842.png

From what I've been able to find through Google, the formula should be giving me either 'Predator' or 'Prey' depending on the selection choice in 'Bird'.

What do I need to change? 

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Frequent Contributor

That is not proper syntax.  Also can just use = for select one

if(${Bird} = 'Hawk' or ${Bird} = 'Eagle', 'Predator', 'Prey')

hope that helps

View solution in original post

0 Kudos
2 Replies
DougBrowning
MVP Frequent Contributor

That is not proper syntax.  Also can just use = for select one

if(${Bird} = 'Hawk' or ${Bird} = 'Eagle', 'Predator', 'Prey')

hope that helps

View solution in original post

0 Kudos
JulietK
Occasional Contributor

Hi Doug, that's worked perfectly, thank you!

I got the original formula from a colleague and it worked for her survey, but turns out she was using it in a select_one field while I was not. 

Thanks again!

0 Kudos