Arcade expression that returns the "Maximum" value, but excludes NULL values.

4130
2
01-07-2017 06:59 AM
Guidovan_der_Kolk2
New Contributor III

I'm trying to use Arcade to create labels that show the highest value from a number of fields. 

  • Field 1 (number field) contains the value -2.7
  • Field 2 (number field) contains the value -2.5
  • Field 3 (number field) is empty (NULL)

If I use the following expression: 

Max (Field1, Field2, Field3)

I get "0" as a result, when I expect to get -2.5 as a result. How can I create an expression that ignores the NULL/empty field? 

0 Kudos
2 Replies
PaulBarker
Esri Contributor

Sorry for the slow reply.  For math operations nulls will be returned as zeros.  My recommendation would be to test the variable for null values before evaluating and substituting it if need be for something you know will not impact the expression.  It might look something like this:

MAX(IIF (isEmpty($feature.Field1),-9999,$feature.Field1),IIF (isEmpty($feature.Field2),-9999,$feature.Field2),IIF (isEmpty($feature.Field3),-9999,$feature.Field3))

SharonUngerer_DNREC
New Contributor II

I like the making it negative -999. Very simple way to remove it from MAX function

0 Kudos