Select to view content in your preferred language

Can a survey have conditional constraint ranges of values?

845
3
Jump to solution
06-07-2023 02:50 PM
Trippetoe
Occasional Contributor III

Hello.

In my survey I have two related fields: Product (select_one) and Rate (decimal). The range of acceptable values in the Rate field depend on what Product is selected. For example, if Product 1 is selected, the constraint is >=0 and <=2. If Product 2 is selected, the constraint is >=0 and <=50, and if Product 3 is selected, the constraint is >=0 and <=100.

As a test, I tried something like the simplified example below, hoping for a small, early win but it fails:

(.>0) and (if(selected(${productId},'prod1')), .<=2,.<=500)

Any thoughts on the equation i should be using?

Trippetoe_0-1686174367095.png

 

0 Kudos
2 Solutions

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

You have an extra paren after prod1.  try this

.>0 and if(selected(${productId},'prod1'), .<=2,.<=500)

If that does not go I tend to write it all out

if(selected(${productId},'prod1'), .>0 and .<=2, .>0 and .<=500)

If that still does not removed the dot and use the full field name notation. I have seen it happen where the short hand . gets messed up when its complicated.

I have done this successfully.

View solution in original post

ZacharySutherby
Esri Regular Contributor

Hello @Trippetoe

There's a bit of a mismatch in the parenthesis. The second parenthesis shouldn't be after the selected() function but instead after the if() statement. 

Try:

(.>0) and (if(selected(${productId},'prod1'), .<=2,.<=500))

 

Thank you,
Zach

View solution in original post

3 Replies
DougBrowning
MVP Esteemed Contributor

You have an extra paren after prod1.  try this

.>0 and if(selected(${productId},'prod1'), .<=2,.<=500)

If that does not go I tend to write it all out

if(selected(${productId},'prod1'), .>0 and .<=2, .>0 and .<=500)

If that still does not removed the dot and use the full field name notation. I have seen it happen where the short hand . gets messed up when its complicated.

I have done this successfully.

ZacharySutherby
Esri Regular Contributor

Hello @Trippetoe

There's a bit of a mismatch in the parenthesis. The second parenthesis shouldn't be after the selected() function but instead after the if() statement. 

Try:

(.>0) and (if(selected(${productId},'prod1'), .<=2,.<=500))

 

Thank you,
Zach
Trippetoe
Occasional Contributor III

Ugh! I hate it when i do that. Both responders are right - i had mismatched parentheses. Thanks to both for being the second and third set of eyes on my code.