Select to view content in your preferred language

Trying to write an IF formula for use in Arcade Expressions in model builder

392
2
Jump to solution
08-24-2023 06:19 AM
AndrewReynoldsDevon
Occasional Contributor

I'm using the calculate field tool in model builder & need to use an IF formula in the expressions box.

So far the code looks like this which doesn't work

if (RouteType) = 'Parental Assistance'; 
Return $feature.ParentalAllowanceMiles;
Else return
$feature.RouteOutwardDistance + $feature.RouteInwardDistance

I need the Field Daily Mileage to recognise if the record has the Route Type of 'Parental Assistance' & then return a the value in that field so no calculation required. But for every other 'Route Type' the original calculation of adding 2 fields together needs to remain.

1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor
if($feature.RouteType == 'Parental Assistance') { 
    return $feature.ParentalAllowanceMiles
}
return $feature.RouteOutwardDistance + $feature.RouteInwardDistance

https://developers.arcgis.com/arcade/guide/operators/

https://developers.arcgis.com/arcade/guide/logic/

 


Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor
if($feature.RouteType == 'Parental Assistance') { 
    return $feature.ParentalAllowanceMiles
}
return $feature.RouteOutwardDistance + $feature.RouteInwardDistance

https://developers.arcgis.com/arcade/guide/operators/

https://developers.arcgis.com/arcade/guide/logic/

 


Have a great day!
Johannes
AndrewReynoldsDevon
Occasional Contributor

Thanks that worked 🙂

0 Kudos