# Arcade expression to find minimum value that is not zero

I am trying to create an Arcade expression to calculate a field in ArcGIS Pro. In my streets feature there are 4 number fields to evaluate. I can easily use the Min() function to do this. The problem that I am having is sometimes there is a 0 in one or more fields. I need the lowest number that is not a 0. In python I had this script which worked well:

``````min([x for x in ( !L_F_ADD!, !L_T_ADD!, !R_F_ADD!, !R_T_ADD!) if x is not 0])
``````

I have tried redoing this in Arcade but can't figure it out. Any ideas?

You are using a coding method called list comprehension which is something that the language Python understands. To the best of my knowledge this technique does not exist in Arcade so you need to approach the problem in a different manner.

Below is some code I worked up and it returns the first non-zero value from a sorted array.

`f1` to `f4` would be your fields.

``````var inArray = [\$feature.f1,\$feature.f2,\$feature.f3,\$feature.f4];
var sortedArray;
sortedArray = sort(inArray);
for(var i in sortedArray)
{
if (sortedArray[i] > 0) break;
}
return sortedArray[i];
``````

As Arcacde is a new scripting language I have found this test page very useful when trying to work out what you want, especially if you are porting from Python.

I also asked this question on Esri’s GeoNet forum and wanted to share the solution that xander_bakker came up with:

``````var minv = 99999;