Arcade, how to write if statement for two conditions?

657
3
Jump to solution
03-03-2023 08:31 AM
JonJones1
Occasional Contributor

Hi all,

I am using the Vary Symbology by Attribute and I need to write an Arcade expression that returns a value if two conditions are met.   Below is what I have, but it has an error somewhere I can't find.

See screenshot attached image for error. 

Is anybody able to offer some help? 

if ($feature.explosives_manufacturer == 'SMASH') &&
($feature.Controller_Name__Current_ == 'ALC') {return 2;}
else {return 1;}

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor
if ($feature.explosives_manufacturer == 'SMASH' &&
$feature.Controller_Name__Current_ == 'ALC') 
{return 2}

else if ($feature.explosives_manufacturer == 'SMASH' &&
$feature.Controller_Name__Current_ == 'QVC') 
{return 3}

else {return 1}

View solution in original post

3 Replies
DavidPike
MVP Frequent Contributor
if ($feature.explosives_manufacturer == 'SMASH' &&
$feature.Controller_Name__Current_ == 'ALC') {return 2}
else {return 1}
JonJones1
Occasional Contributor

This is perfect!   I do have a quick follow-up, how could I expand the code to write more statements?  Such as this, but this is wrong and doesn't work; 

if ($feature.explosives_manufacturer == 'SMASH' &&
$feature.Controller_Name__Current_ == 'ALC') {return 2}
else {return 1}

||

if ($feature.explosives_manufacturer == 'SMASH' &&
$feature.Controller_Name__Current_ == 'QVC') {return 3}
else {return 1}

Had to edit the code in the post for a clearer explanation. 

 

 

 

 

 

0 Kudos
DavidPike
MVP Frequent Contributor
if ($feature.explosives_manufacturer == 'SMASH' &&
$feature.Controller_Name__Current_ == 'ALC') 
{return 2}

else if ($feature.explosives_manufacturer == 'SMASH' &&
$feature.Controller_Name__Current_ == 'QVC') 
{return 3}

else {return 1}