AnsweredAssumed Answered

How to nest Arcade If statements

Question asked by njbegg on Jun 24, 2019
Latest reply on Jul 25, 2019 by xander_bakker

I am working through a loop of intersecting layers, in which I want to choose the largest value.

 

I have tried to use create a list of numbers using += .  This worked fine when I was using a combo of text and numbers, but because I am now just looking at numbers it sums the values, == replaces the values.  I could not see how to make a list which I could then use the MAX function with.

 

My next attempt was to nest an if statement so that I am only getting the largest number out but I have an illegal return statement.

 

Below is an example of what I am currently doing.

 

var intersectLayer = Intersects(FeatureSetByName($map, "layer"), $feature)

var Zones = "";

var Zones1 = "";

 

for (var f in intersectLayer){

   if(Zones == ""){

      Zones = f.Shape__Area

   } else {

   Zones1 = f.Shape__Area

      if (Zones < Zones1){

      Zones == Zones1

      }else{

      Zones1 == ""

      }

}

}

 

Xander Bakker Is this something you can help me with?  I'm expecting there to be a much easier way then I have thought of yet.

Outcomes