Arcade script not calculating properly

290
3
Jump to solution
04-01-2026 05:57 AM
JustinBernard1886
Regular Contributor

Hello,

I have a bit of a conundrum.

I have a simple arcade script that returns a calculation based on a value. When I entered "ABT", the script makes the correct calculation, but when I enter "Park" or "Street", the script returns "750" 
Any reason why the else if function wouldnt work? 

Here is the script

var SpacTypeClass = $feature.SpactypeCLASS;
var API = ($feature.Appraised_Trunk_Increase)


if (SpacTypeClass == 'ABT') {
    return ((API * 6.51) + 5000);
} else if (SpacTypeClass == 'Street') {
    return ((API * 6.51) + 750);
} else if (SpacTypeClass == 'Park') {
    return ((API * 6.51) + 750);
}

 

Thanks,

Justin 

0 Kudos
1 Solution

Accepted Solutions
JustinBernard1886
Regular Contributor

Hey guys,

Thanks for all the help. It hit me, that the issue was the order of the attributes rules. I needed to rearrange them so the API rule calculated first. Before it was calculating AFTER the rule I posted, so it was returning zero. I reordered the rules and I am now getting the correct result.

Thanks for the help!

 

View solution in original post

3 Replies
AlfredBaldenweck
MVP Frequent Contributor

It worked for me? Best guess is you just don't have any values in the API field for the other two, or the value is 0.

Screenshot 2026-04-01 071752.png

Neal_t_k
MVP Regular Contributor

Have you considered a When statement instead of the nested if else?

something like:

var spClass =
  When(
    SpacTypeClass == 'ABT', 5000,
    SpacTypeClass == 'Street', 750,
    SpacTypeClass == 'Park', 750,  
  );
return (API * 6.51) + spClass;

 

Also if it is just returning  "750" for Street and Park, your calc may be working but API is returning 0 for those cases.  Double check that an API exists for those.

0 Kudos
JustinBernard1886
Regular Contributor

Hey guys,

Thanks for all the help. It hit me, that the issue was the order of the attributes rules. I needed to rearrange them so the API rule calculated first. Before it was calculating AFTER the rule I posted, so it was returning zero. I reordered the rules and I am now getting the correct result.

Thanks for the help!