HOW TO
In ArcGIS Online, subtracting field values from a specified value may return negative results, as shown in the image below.
Having results devoid of negative values when substracting is ideal in situations involving boundary protection, where negative values may return unexpected results on the map, and logical consistency, where returning '0' as the result maintains a meaningful interpretation in the output.
This article provides the workflow to subtract field values and exclude negative results using Arcade in ArcGIS Online.
var <variableName1> = $feature.<fieldName>;
var <variableName2>= <subtractionValue>;
IIf(<variableName1> < value, 0, <variableName1> - <variableName2>);
The code block below shows an example of the full working script.
var subtract_from = $feature.Subtract; var value = 1200; IIf(subtract_from < value, 0, subtract_from - value);
The image below shows non-negative values in the field when the subtraction results in a negative number.
Article ID: 000031849
Get help from ArcGIS experts
Download the Esri Support App