<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Help with returning value from 2 Intersecting Layers with Arcade in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170958#M45895</link>
    <description>&lt;P&gt;Hi brains trust. I'm trying to use Arcade to calculate a value in Field Maps based on the intersection of the new point feature with 2 underlying polygons layers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've successfully managed to get a value from a field in one layer, but I want it to test it for null values and then return a value from a second layer if null = true.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;var BufferedFeature = Buffer($feature, 20, 'meters')
var intersectLayer1 = Intersects(FeatureSetByName($map, 'Layer1'),BufferedFeature)
var intersectLayer2 = Intersects(FeatureSetByName($map, 'Layer2'),BufferedFeature)

for (var f in intersectLayer1){
    var name1 = f.Field
}
for (var f in intersectLayer2){
    var name2 = f.Field
}

IIf(name1=='',name2,name1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;var BufferedFeature = Buffer($feature, 20, 'meters')
var intersectLayer1 = Intersects(FeatureSetByName($map, 'Layer1'),BufferedFeature)
var intersectLayer2 = Intersects(FeatureSetByName($map, 'Layer2'),BufferedFeature)

for (var f in intersectLayer1){
    IsEmpty(f.Field)=='true';
        for (var f in intersectLayer2){
            return f.Field
        }
    return f1.Field
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried a few variations of the above codes, and the Field value from Layer 1 returns correctly when it does intersect, but can't get it to return the Field value from Layer 2 when Layer 1 does NOT intersect (and Layer 2 does).&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 May 2022 05:07:31 GMT</pubDate>
    <dc:creator>LindsayRaabe_FPCWA</dc:creator>
    <dc:date>2022-05-05T05:07:31Z</dc:date>
    <item>
      <title>Help with returning value from 2 Intersecting Layers with Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170958#M45895</link>
      <description>&lt;P&gt;Hi brains trust. I'm trying to use Arcade to calculate a value in Field Maps based on the intersection of the new point feature with 2 underlying polygons layers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've successfully managed to get a value from a field in one layer, but I want it to test it for null values and then return a value from a second layer if null = true.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;var BufferedFeature = Buffer($feature, 20, 'meters')
var intersectLayer1 = Intersects(FeatureSetByName($map, 'Layer1'),BufferedFeature)
var intersectLayer2 = Intersects(FeatureSetByName($map, 'Layer2'),BufferedFeature)

for (var f in intersectLayer1){
    var name1 = f.Field
}
for (var f in intersectLayer2){
    var name2 = f.Field
}

IIf(name1=='',name2,name1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;var BufferedFeature = Buffer($feature, 20, 'meters')
var intersectLayer1 = Intersects(FeatureSetByName($map, 'Layer1'),BufferedFeature)
var intersectLayer2 = Intersects(FeatureSetByName($map, 'Layer2'),BufferedFeature)

for (var f in intersectLayer1){
    IsEmpty(f.Field)=='true';
        for (var f in intersectLayer2){
            return f.Field
        }
    return f1.Field
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried a few variations of the above codes, and the Field value from Layer 1 returns correctly when it does intersect, but can't get it to return the Field value from Layer 2 when Layer 1 does NOT intersect (and Layer 2 does).&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 05:07:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170958#M45895</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2022-05-05T05:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help with returning value from 2 Intersecting Layers with Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170960#M45896</link>
      <description>&lt;LI-CODE lang="javascript"&gt;var featureLayer1 = First(intersectLayer1)
var featureLayer2 = First(intersectLayer2)

if(featureLayer1 != null) {
    return featureLayer1.Field
}
if(featureLayer2 != null) {
    return featureLayer2.Field
}
return "nothing found"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or (same output, a little shorter)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for(var f in intersectLayer1) {
    return f.Field
}
for(var f in intersectLayer2) {
    return f.Field
}
return "nothing found"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 05:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170960#M45896</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-05-05T05:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with returning value from 2 Intersecting Layers with Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170961#M45897</link>
      <description>&lt;P&gt;Oh, my answer checks if there are any features in intersectLayer1. If you want to check for null values in Field, you can do that like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// returns the value of the first non-empty field "Field"
for(var f in intersectLayer1) {
    if(!IsEmpty(f.Field)) {
        return f.Field
    }
}
for(var f in intersectLayer2) {
    if(!IsEmpty(f.Field)) {
        return f.Field
    }
}
return "nothing found"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 05 May 2022 05:25:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170961#M45897</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-05-05T05:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with returning value from 2 Intersecting Layers with Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170965#M45898</link>
      <description>&lt;P&gt;You're a champ! That works perfectly. Thank you muchly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 05:43:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/help-with-returning-value-from-2-intersecting/m-p/1170965#M45898</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2022-05-05T05:43:45Z</dc:date>
    </item>
  </channel>
</rss>

