I need to return an icon based on an attribute value and I am not sure if I need to you when or Iif statement...or something else. I believe I need to change something in lines 3-7 but I am new to Advanced formatting with arcade. This is what I have tried:
and
Solved! Go to Solution.
Using When is fine, but you need a final "default value" that the function will return if none of the conditions are met.
var icon = When(
condition1, 'this',
condition2, 'that',
condition3, 'the other',
'something else'
)
Iif is for true/false situations, and can only return one of two values.
There's also Decode, which takes an input value and compares it against a list of other values, similar to what you're doing here. As with When, you need a final default value.
var icon = Decode(
s,
'#00ff00', 'green',
'#ff0000', 'red',
'#ffff00', 'yellow',
'something else'
)
Using When is fine, but you need a final "default value" that the function will return if none of the conditions are met.
var icon = When(
condition1, 'this',
condition2, 'that',
condition3, 'the other',
'something else'
)
Iif is for true/false situations, and can only return one of two values.
There's also Decode, which takes an input value and compares it against a list of other values, similar to what you're doing here. As with When, you need a final default value.
var icon = Decode(
s,
'#00ff00', 'green',
'#ff0000', 'red',
'#ffff00', 'yellow',
'something else'
)