<?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 Combine multiple layers (point, line and polygon) into new feature set using data expression for Dashboard in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350363#M8729</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a new data expression for an indicator element, which will combine the three layers from my map (which share the same attributes, but have different geometry types). I currently have an indicator for my point, line and polygon layer, but I would like a single indicator which will be able to count the number of features in each layer and sum together.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used various combinations of codes from other queries, but still have the same error message "&lt;SPAN&gt;Test execution error: Compilation error - Line : 4, 33: Identifier not recognized. Verify test data." Here is the code that I have so far:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Portal
Portal("https://www.arcgis.com/");
// Create FeatureSet for points
var fs1 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&amp;amp;sublayer=0', 0, ['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);

// Create Featureset for lines
var fs2 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&amp;amp;sublayer=1', 0,
['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);

//Create Featureset for polygons
var fs3 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&amp;amp;sublayer=2', 0,
['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);

// Create empty feature array and feat object for output
var features = [];
var feat;

// Iterate fs1
for (var feature in fs1) {
    
    // Filter points by polygon
    //var pts = Contains(feature, fs2);
    
    // Create feature with aggregated values
    feat = { 
        'attributes': { 
            'objecttype': ['PointObject'],
            'NatureReserve': feature['NatureReserve'],
            'Priority': feature['Priority'],
            'IssueCategory': feature['IssueCategory'],
            'Notes': feature['Notes'],
            'RecordDate': feature['RecordDate'],
            'CompletionDate': feature['CompletionDate'],
            'CompletedBy': feature['CompletedBy'],
            'CreationDate': feature['CreationDate'],
            'GlobalID': feature['GlobalID']
        }
    };
    
    // Push feature into array
    Push(features, feat);
};

for (var feature in fs2) {
    
    // Filter points by polygon
    //var pts = Contains(feature, fs2);
    
    // Create feature with aggregated values
    feat = { 
        'attributes': { 
            'objecttype': ['PointObject'],
            'NatureReserve': feature['NatureReserve'],
            'Priority': feature['Priority'],
            'IssueCategory': feature['IssueCategory'],
            'Notes': feature['Notes'],
            'RecordDate': feature['RecordDate'],
            'CompletionDate': feature['CompletionDate'],
            'CompletedBy': feature['CompletedBy'],
            'CreationDate': feature['CreationDate'],
            'GlobalID': feature['GlobalID']
        }
    };
    
    // Push feature into array
    Push(features, feat);
};

// Create dict for output FeatureSet
var out_dict = { 
    'fields': [
        {'name': 'objecttype', 'type': 'esriFieldTypeString'},
        {'name': 'NatureReserve', 'type': 'esriFieldTypeString'},
        {'name': 'Priority', 'type': 'esriFieldTypeString'},
        {'name': 'IssueCategory', 'type': 'esriFieldTypeString'},
        {'name': 'Notes', 'type': 'esriFieldTypeString'},
        {'name': 'RecordDate', 'type': 'esriFieldTypeDate'},
        {'name': 'CompletionDate', 'type': 'esriFieldTypeDate'},
        {'name': 'CompletedBy', 'type': 'esriFieldTypeString'},
        {'name': 'CreationDate', 'type': 'esriFieldTypeDate'},
        {'name': 'GlobalID', 'type': 'esriFieldTypeGlobalID'},
    ],
  'geometryType': '', 
  'features': features 
}; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I am very new to data expressions so any and all suggestions would be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 16 Nov 2023 17:51:04 GMT</pubDate>
    <dc:creator>CatherineCoe</dc:creator>
    <dc:date>2023-11-16T17:51:04Z</dc:date>
    <item>
      <title>Combine multiple layers (point, line and polygon) into new feature set using data expression for Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350363#M8729</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a new data expression for an indicator element, which will combine the three layers from my map (which share the same attributes, but have different geometry types). I currently have an indicator for my point, line and polygon layer, but I would like a single indicator which will be able to count the number of features in each layer and sum together.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used various combinations of codes from other queries, but still have the same error message "&lt;SPAN&gt;Test execution error: Compilation error - Line : 4, 33: Identifier not recognized. Verify test data." Here is the code that I have so far:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Portal
Portal("https://www.arcgis.com/");
// Create FeatureSet for points
var fs1 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&amp;amp;sublayer=0', 0, ['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);

// Create Featureset for lines
var fs2 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&amp;amp;sublayer=1', 0,
['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);

//Create Featureset for polygons
var fs3 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&amp;amp;sublayer=2', 0,
['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);

// Create empty feature array and feat object for output
var features = [];
var feat;

// Iterate fs1
for (var feature in fs1) {
    
    // Filter points by polygon
    //var pts = Contains(feature, fs2);
    
    // Create feature with aggregated values
    feat = { 
        'attributes': { 
            'objecttype': ['PointObject'],
            'NatureReserve': feature['NatureReserve'],
            'Priority': feature['Priority'],
            'IssueCategory': feature['IssueCategory'],
            'Notes': feature['Notes'],
            'RecordDate': feature['RecordDate'],
            'CompletionDate': feature['CompletionDate'],
            'CompletedBy': feature['CompletedBy'],
            'CreationDate': feature['CreationDate'],
            'GlobalID': feature['GlobalID']
        }
    };
    
    // Push feature into array
    Push(features, feat);
};

for (var feature in fs2) {
    
    // Filter points by polygon
    //var pts = Contains(feature, fs2);
    
    // Create feature with aggregated values
    feat = { 
        'attributes': { 
            'objecttype': ['PointObject'],
            'NatureReserve': feature['NatureReserve'],
            'Priority': feature['Priority'],
            'IssueCategory': feature['IssueCategory'],
            'Notes': feature['Notes'],
            'RecordDate': feature['RecordDate'],
            'CompletionDate': feature['CompletionDate'],
            'CompletedBy': feature['CompletedBy'],
            'CreationDate': feature['CreationDate'],
            'GlobalID': feature['GlobalID']
        }
    };
    
    // Push feature into array
    Push(features, feat);
};

// Create dict for output FeatureSet
var out_dict = { 
    'fields': [
        {'name': 'objecttype', 'type': 'esriFieldTypeString'},
        {'name': 'NatureReserve', 'type': 'esriFieldTypeString'},
        {'name': 'Priority', 'type': 'esriFieldTypeString'},
        {'name': 'IssueCategory', 'type': 'esriFieldTypeString'},
        {'name': 'Notes', 'type': 'esriFieldTypeString'},
        {'name': 'RecordDate', 'type': 'esriFieldTypeDate'},
        {'name': 'CompletionDate', 'type': 'esriFieldTypeDate'},
        {'name': 'CompletedBy', 'type': 'esriFieldTypeString'},
        {'name': 'CreationDate', 'type': 'esriFieldTypeDate'},
        {'name': 'GlobalID', 'type': 'esriFieldTypeGlobalID'},
    ],
  'geometryType': '', 
  'features': features 
}; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I am very new to data expressions so any and all suggestions would be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 17:51:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350363#M8729</guid>
      <dc:creator>CatherineCoe</dc:creator>
      <dc:date>2023-11-16T17:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Combine multiple layers (point, line and polygon) into new feature set using data expression for Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350371#M8730</link>
      <description>&lt;P&gt;You haven't instantiated the variable "p" used in your FeatureSetByPortalItem calls. Change line 2 to&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var p = Portal("https://www.arcgis.com/");&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Nov 2023 17:58:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350371#M8730</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-11-16T17:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Combine multiple layers (point, line and polygon) into new feature set using data expression for Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350688#M8734</link>
      <description>&lt;P&gt;Thank you. I've now instantiated variable "p" but my output still won't run. It now says "&lt;SPAN&gt;Test execution error: Unknown Error. Verify test data"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 09:57:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350688#M8734</guid>
      <dc:creator>CatherineCoe</dc:creator>
      <dc:date>2023-11-17T09:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Combine multiple layers (point, line and polygon) into new feature set using data expression for Dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350765#M8736</link>
      <description>&lt;P&gt;Do you have access to the source? When I run this part of the code in the &lt;A href="https://developers.arcgis.com/arcade/playground/" target="_self"&gt;Playground&lt;/A&gt;, I get the same error since I don't have permissions to see that item.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var p = Portal("https://www.arcgis.com/");
// Create FeatureSet for points
var fs1 = FeatureSetByPortalItem(p,'2b84b6b511584a34807749f5d9969dd4&amp;amp;sublayer=0', 0, ['NatureReserve','Priority','IssueCategory','Notes','RecordDate','CompletionDate','CompletedBy','CreationDate','GlobalID'], true);
return fs1&lt;/LI-CODE&gt;&lt;P&gt;Have you included the line "return FeatureSet(out_Dict);" to return the FeatureSet?&lt;/P&gt;&lt;P&gt;Use the &lt;A href="https://developers.arcgis.com/arcade/guide/debugging/" target="_self"&gt;console&lt;/A&gt; in various places in your code to make sure it's not breaking down somewhere. For example, examine the features variable at the completion of each loop.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 14:21:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/combine-multiple-layers-point-line-and-polygon/m-p/1350765#M8736</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-11-17T14:21:30Z</dc:date>
    </item>
  </channel>
</rss>

