<?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: Arcade Expression Combining Multiple Layers  For Graph in Dashboard in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-combining-multiple-layers-for/m-p/1596306#M10903</link>
    <description>&lt;P&gt;I was about to get both my expression and the one above to work. My problem was in the FeatureSetByPortalItem. I had the incorrect layerid. The zero needed to be 1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ian_Nelson_0-1742242448483.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/128090i4229C01EE702E09B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ian_Nelson_0-1742242448483.png" alt="Ian_Nelson_0-1742242448483.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Mar 2025 20:14:36 GMT</pubDate>
    <dc:creator>Ian_Nelson</dc:creator>
    <dc:date>2025-03-17T20:14:36Z</dc:date>
    <item>
      <title>Arcade Expression Combining Multiple Layers  For Graph in Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-combining-multiple-layers-for/m-p/1594939#M10871</link>
      <description>&lt;P&gt;Hello, I'm attempting to create an arcade script that combines three layers (point, line, and polygon) with the same schema and then displaying that in a serial chart or pie chart. When I attempt to run the expression below the dashboard expression editor has this as the output. Any help would be greatly apricated! I've been staring at this for hours...&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ian_Nelson_1-1741811232339.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/127788iE6A034F192793334/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ian_Nelson_1-1741811232339.png" alt="Ian_Nelson_1-1741811232339.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var p = Portal("https://maps.xyzxyzxy.com/portal/");

var point_field = FeatureSetByPortalItem(p,***itemid***,0,["Cat28Code2025","Notes2025","Ocondition2025","RBU"],false);

var polyline_field = FeatureSetByPortalItem(p,"***itemid***",0,["Cat28Code2025","Notes2025","Ocondition2025","RBU"],false);

var polygon_field = FeatureSetByPortalItem(p,"***itemid***",0,["Cat28Code2025","Notes2025","Ocondition2025","RBU"],false);

var combinedDict = {
    fields:[
        {name : "CatCode",type : "esriFieldTypeSmallInteger"},
        {name : "Notes",type : "esriFieldTypeString"},
        {name : "Condition",type : "esriFieldTypeDouble"},
        {name : "BusinessUnit",type : "esriFieldTypeString"},
        {name : "Source", type : "esriFieldTypeString"},
    ],
    'geometryType':"",
    'features':[], //create empty array for features
    };

var i = 0;
//Loop through each FeatureSet and populate feature array
for (var m in point_field){
    combinedDict.features[i] = {
        attributes: {
            CatCode : m["Cat28Code2025"],
            Notes : m["Notes2025"],
            Condition : m["Ocondition2025"],
            BusinessUnit : m["RBU"],
            Source : "Point"
        },
   };
i++;
}  
for (var m in polyline_field){
    combinedDict.features[i] = {
        attributes: {
            CatCode : m["Cat28Code2025"],
            Notes : m["Notes2025"],
            Condition : m["Ocondition2025"],
            Source : "Polyline"
        },
    };
i++;
}  
for (var m in polygon_field){
    combinedDict.features[i] = {
        attributes: {
            CatCode : m["Cat28Code2025"],
            Notes : m["Notes2025"],
            Condition : m["Ocondition2025"],
            Source : "Polygon"
        },
    };
i++;
}  
// Return dictionary cast as a feature set
return FeatureSet(Text(combinedDict));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 20:33:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-combining-multiple-layers-for/m-p/1594939#M10871</guid>
      <dc:creator>Ian_Nelson</dc:creator>
      <dc:date>2025-03-12T20:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression Combining Multiple Layers  For Graph in Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-combining-multiple-layers-for/m-p/1595097#M10873</link>
      <description>&lt;P&gt;Your issue is that you have this in your code trying to populate an array but it is set to populate a dictionary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;combinedDict.features[i]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you want to change it to look like the example below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for (var m in polygon_field){
    var A = {
        attributes: {
            CatCode : m["Cat28Code2025"],
            Notes : m["Notes2025"],
            Condition : m["Ocondition2025"],
            Source : "Polygon"
            }
        }
    Push( combinedDict.features , A )
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also throwing this example in here to showcase a simpler manner to write the same code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function CreateDictValues( InArray , InFeature , Fields , Geometry ){
	for( var row in InFeature ){
		var Values = iif( !IsEmpty( Geometry ) , { Source : Geometry } , {} )
		var Valid = False
		for( var field in row ){
			if( HasKey( Fields , field ) ){
				field = Fields[ field ]
				Values[ field ] = i[ field ]
				Valid = True
				}
			}
		if( Valid ){ Push( InArray , { attributes: Values } ) }
		}
	return InArray
	}
//Loop through each FeatureSet and populate feature array
var PopValues = []
var F = {"Cat28Code2025":'CatCode',"Notes2025":'Notes',"Ocondition2025":"Condition","RBU":"BusinessUnit"}
CreateDictValues( PopValues , point_field  , F , "Point" )
CreateDictValues( PopValues , polyline_field , F , "Point" )
CreateDictValues( PopValues , polygon_field , F , "Point" )

// Return dictionary cast as a feature set
var combinedDict = {
    fields:[
        {name : "CatCode",type : "esriFieldTypeSmallInteger"},
        {name : "Notes",type : "esriFieldTypeString"},
        {name : "Condition",type : "esriFieldTypeDouble"},
        {name : "BusinessUnit",type : "esriFieldTypeString"},
        {name : "Source", type : "esriFieldTypeString"},
    ],
    'geometryType':"",
    'features':PopValues ,
    }
return FeatureSet(Text(combinedDict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 12:23:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-combining-multiple-layers-for/m-p/1595097#M10873</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-03-13T12:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression Combining Multiple Layers  For Graph in Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-combining-multiple-layers-for/m-p/1596306#M10903</link>
      <description>&lt;P&gt;I was about to get both my expression and the one above to work. My problem was in the FeatureSetByPortalItem. I had the incorrect layerid. The zero needed to be 1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ian_Nelson_0-1742242448483.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/128090i4229C01EE702E09B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ian_Nelson_0-1742242448483.png" alt="Ian_Nelson_0-1742242448483.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2025 20:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-combining-multiple-layers-for/m-p/1596306#M10903</guid>
      <dc:creator>Ian_Nelson</dc:creator>
      <dc:date>2025-03-17T20:14:36Z</dc:date>
    </item>
  </channel>
</rss>

