<?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 Re: Within() Arcade Function and multi-layer feature services in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656194#M66542</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;- that worked! Looks like adding First() is what I needed. Seems odd to me that it didn't need that function for the parcel layer, but perhaps there is some overlapping geometry in the zoning that I need to find.&lt;BR /&gt;&lt;BR /&gt;Thank you and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/22623"&gt;@RPGIS&lt;/a&gt;&amp;nbsp;for sticking with me on this.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Oct 2025 13:17:01 GMT</pubDate>
    <dc:creator>AmyRoust</dc:creator>
    <dc:date>2025-10-08T13:17:01Z</dc:date>
    <item>
      <title>Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655583#M66513</link>
      <description>&lt;P&gt;Is there a trick to using the Within function when referencing a layer in a multi-layer feature layer? I used a simple Within function to add the intersecting parcel PIN number to an address point's pop-up, but when I try to get its zoning, here's what happens:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AmyRoust_0-1759771648220.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141398i630247187BB5146C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AmyRoust_0-1759771648220.png" alt="AmyRoust_0-1759771648220.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I comment out the Within function and just tell it to return all zoning data, it works:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AmyRoust_1-1759771695741.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141399i34373AD28500AD40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AmyRoust_1-1759771695741.png" alt="AmyRoust_1-1759771695741.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The difference between my parcel feature layer and my zoning feature layer is that the zoning layer has three layers in it:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AmyRoust_3-1759771834658.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141401i4C25ADE21058D2AA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AmyRoust_3-1759771834658.png" alt="AmyRoust_3-1759771834658.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The FeatureSetByName function doesn't seem to care that it's in a group, but maybe Within does?&lt;/P&gt;&lt;P&gt;I did try adding the Lawrence Zoning District sublayer by itself to the map, but I got the same results.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AmyRoust_4-1759771990616.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141402i64CC1B88A81E2FF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AmyRoust_4-1759771990616.png" alt="AmyRoust_4-1759771990616.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 17:33:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655583#M66513</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2025-10-06T17:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655627#M66514</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/82823"&gt;@AmyRoust&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;So the within function returns a feature set of the features that fall within the specified layer. If you have an instance where some layers may overlap others then what I might suggest is any of the following.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var FS = FeatureSetByName($map, 'Zoning Districts - Lawrence Zoning District',['ZoningDistrict'],True)
var Address = $feature
if( TypeOf(Geometry($feature)) == 'Polygon' ){ Address = Centroid($feature) }
var AddrWithin = Within(address,FS)
iif( Count(AddrWithin)&amp;gt;0, AddrWithin, 'No features are within the layer')
/*
Note: the intersects function can also be used if the input layer is a point feature.
*/&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 06 Oct 2025 20:11:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655627#M66514</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-10-06T20:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655641#M66515</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/22623"&gt;@RPGIS&lt;/a&gt;&amp;nbsp;- no luck, but I appreciate the suggestion.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AmyRoust_0-1759783836518.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141420i6327705DCED862B8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AmyRoust_0-1759783836518.png" alt="AmyRoust_0-1759783836518.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 20:50:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655641#M66515</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2025-10-06T20:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655662#M66518</link>
      <description>&lt;P&gt;Then it might helpful then to use the intersects function to get the information that you need. It may also require that you loop through multiple features to get a dictionary of field values to pull from.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 22:08:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655662#M66518</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-10-06T22:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655688#M66521</link>
      <description>&lt;P&gt;It doesn't matter if you have the layer within a group layer. This works on a test I set up.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByName($map, "USA Census States")
var output = Within($feature,FS)

return { 
	type : 'text', 
	text : first(output).STATE_NAME
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KenBuja_0-1759791417342.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141427i8E9B048E154FCB93/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KenBuja_0-1759791417342.png" alt="KenBuja_0-1759791417342.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Did you test the code on an actual feature in the Zoning District? Running the code in the editor will use the first feature in the FeatureSet, which may or may not give you a feature within the Zoning District layer. You can use a feature you know will work by filtering the parcel to a specific one. In my example, I can filter the earthquakes to a specific event to test it out.&lt;/P&gt;&lt;P&gt;This code&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var feat = First(Filter($layer, "id = 'mb90114598'"))
var fs = FeatureSetByName($map, "USA Census States")
var output = Within(feat,FS)
return output
return { 
	type : 'text', 
	text : first(output).STATE_NAME
}&lt;/LI-CODE&gt;&lt;P&gt;returns this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KenBuja_1-1759791971984.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141428i9868B014851BD7F4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KenBuja_1-1759791971984.png" alt="KenBuja_1-1759791971984.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The code in your latest post fails because you're supplying an incorrect name for the FeatureSetByName function, which returns a null. When used in the WIthin function, it's being interpreted as a null feature in the Geometry &lt;A href="https://developers.arcgis.com/arcade/function-reference/geometry_functions/#within" target="_self"&gt;Within&lt;/A&gt; function (which returns a boolean) instead of the FeatureSet &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#within" target="_self"&gt;Within&lt;/A&gt; function (which returns a FeatureSet)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 23:19:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655688#M66521</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-10-06T23:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655798#M66523</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Correct me if I am wrong but it might appear that&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/82823"&gt;@AmyRoust&lt;/a&gt;&amp;nbsp;is referencing a grouped layer which, if it is setup correctly, should be a single service in which case the Within function should work. However, if it is created as separate feature services which are then grouped in the map then that would require a different work around. In which case&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/82823"&gt;@AmyRoust&lt;/a&gt;&amp;nbsp;could try one of the following below.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Option 1: using union then the within function
var FSets = [
    FeatureSetByName($map,'ConditionalZoning'),['*'],True),
    FeatureSetByName($map,'LawrenceZoningDistrict'),['*'],True),
    FeatureSetByName($map,'DouglasCountyZoningDistrict'),['*'],True)
    ]

var UnionSets = Union(FSets)
var Address = $feature
var Check = Within(Address,UnionSets)
iif( TypeOf( Check ) == 'FeatureSet', Check, 'Nothing Within')
	
// Option 2: looping through a list of layers and getting the appropriate values
var FSets = [
    FeatureSetByName($map,'ConditionalZoning'),['*'],True),
    FeatureSetByName($map,'LawrenceZoningDistrict'),['*'],True),
    FeatureSetByName($map,'DouglasCountyZoningDistrict'),['*'],True)
    ]

var Address = $feature

var TextValues = []
for( var fs in FSets ){
	fs = FSets[i]
	var V = First(Intersects(Address,fs))
	if(TypeOf(intfs)=='Feature'){ Push(TextValues,V['&amp;lt;fieldname&amp;gt;']) }
	}
iif( Count(TextValues)&amp;gt;0, Concatenate(TextValues,'\n'), 'Address does not fall within')&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 07 Oct 2025 13:18:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1655798#M66523</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-10-07T13:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656005#M66532</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/22623"&gt;@RPGIS&lt;/a&gt;&amp;nbsp;your first assumption is correct - all three layers are published as one service. I only need to pull the intersecting value from the Lawrence Zoning District layer, but it wouldn't hurt to pull the value from the Conditional Zoning layer. Either way, neither Within() nor Intersects() works with the zoning service. It does work with our parcel service.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AmyRoust_0-1759867861002.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141496i20836073C4DCF17D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AmyRoust_0-1759867861002.png" alt="AmyRoust_0-1759867861002.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The parcel service just has one layer, which is what led me to suspect that the multi-layer service was the issue for me. I took that exact block of code in the screenshot above and just swapped out parcel for zoning, and it returns an error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;you asked, "&lt;SPAN&gt;Did you test the code on an actual feature in the Zoning District?" Yes, I did try that. No luck.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;All three of these services are public, so if anyone wants to test on the actual data, here are links to the item pages in AGO:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Address Point:&amp;nbsp;&lt;A href="https://lawrenceks.maps.arcgis.com/home/item.html?id=0e4a33c0f05e483284f046c220b8f0c0" target="_blank"&gt;https://lawrenceks.maps.arcgis.com/home/item.html?id=0e4a33c0f05e483284f046c220b8f0c0&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Parcel:&amp;nbsp;&lt;A href="https://lawrenceks.maps.arcgis.com/home/item.html?id=08285f4b4aca41a785afcc47c5044d2e" target="_blank"&gt;https://lawrenceks.maps.arcgis.com/home/item.html?id=08285f4b4aca41a785afcc47c5044d2e&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Zoning Districts:&amp;nbsp;&lt;A href="https://lawrenceks.maps.arcgis.com/home/item.html?id=8cfd05010c2d4cc499cc701c91e3c2b0" target="_blank"&gt;https://lawrenceks.maps.arcgis.com/home/item.html?id=8cfd05010c2d4cc499cc701c91e3c2b0&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2025 20:15:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656005#M66532</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2025-10-07T20:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656025#M66533</link>
      <description>&lt;P&gt;I've used your layers in a map and it works as expected. The code I'm using is&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByName($map, "Lawrence Zoning District", ["ZoningDistrict"]);
var WithinFS = Within($feature, fs);
iif(
  Count(WithinFS) == 0,
  "Not in a zoning district.",
  First(WithinFS).ZoningDistrict
);&lt;/LI-CODE&gt;&lt;P&gt;which returns this when run in the text editor (using iif to return a message if there are no features returned by the Within)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KenBuja_0-1759870093203.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141499i7D0C3FB1E84045AA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KenBuja_0-1759870093203.png" alt="KenBuja_0-1759870093203.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and this in the popup ("R-2", circled in red)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-10-07 165126.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141503i86A04CD4C3AA953B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2025-10-07 165126.png" alt="Screenshot 2025-10-07 165126.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2025 20:58:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656025#M66533</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-10-07T20:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656036#M66534</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/82823"&gt;@AmyRoust&lt;/a&gt;&amp;nbsp;. Try the following.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var P = Portal('https://lawrenceks.maps.arcgis.com/')
var Addr = FeatureSetByPortalItem(P, '0e4a33c0f05e483284f046c220b8f0c0',0,['*'],True)
var Parcs = FeatureSetByPortalItem(P, '8cfd05010c2d4cc499cc701c91e3c2b0','*',['*'],True)

var Test = []
for( var i in Parcs){
  var N = First(Intersects( Addr, Geometry(i)))
  if( TypeOf(N)=='Feature' ){
    N = Dictionary(N).attributes
    Console(N)
    Push(Test,N)
    }
  if( Count(Test) &amp;lt;= 10 ){Break}
  }
If( Count(Test)&amp;gt;0){ Console(Concatenate(Test,'\n')) }&lt;/LI-CODE&gt;&lt;P&gt;You can play around with it in the &lt;A title="Playground" href="https://developers.arcgis.com/arcade/playground/" target="_blank" rel="noopener"&gt;Arcade Playground&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2025 21:20:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656036#M66534</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-10-07T21:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Within() Arcade Function and multi-layer feature services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656194#M66542</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;- that worked! Looks like adding First() is what I needed. Seems odd to me that it didn't need that function for the parcel layer, but perhaps there is some overlapping geometry in the zoning that I need to find.&lt;BR /&gt;&lt;BR /&gt;Thank you and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/22623"&gt;@RPGIS&lt;/a&gt;&amp;nbsp;for sticking with me on this.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 13:17:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/within-arcade-function-and-multi-layer-feature/m-p/1656194#M66542</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2025-10-08T13:17:01Z</dc:date>
    </item>
  </channel>
</rss>

