<?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: How to create a featureset from two other featuresets in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1096970#M5055</link>
    <description>&lt;P&gt;Hello, as it turned out the solution appears not to be 100% correct and I am at a loss to figure out why.&lt;/P&gt;&lt;P&gt;It seems that each array contains less features that the source featureclass and&amp;nbsp; the combined set has still fewer features.&lt;/P&gt;&lt;P&gt;For example, I have 3197 points.&amp;nbsp; immediately after created the 'featureDataPoint is shows 3095 -- as reported via a console message using the count() function.&lt;/P&gt;&lt;P&gt;The total number of the two layers combined starts at 7011 and in the arrays are 6855 and in the final "newSet" is 5303&lt;/P&gt;&lt;P&gt;Here is my current code:&lt;/P&gt;&lt;P&gt;// Write an expression that returns a FeatureSet.&lt;BR /&gt;// Documentation: &lt;A href="https://arcg.is/3c419TD" target="_blank"&gt;https://arcg.is/3c419TD&lt;/A&gt;&lt;BR /&gt;// Samples: &lt;A href="https://arcg.is/38SEWWz" target="_blank"&gt;https://arcg.is/38SEWWz&lt;/A&gt;&lt;/P&gt;&lt;P&gt;var feat_arr = []&lt;/P&gt;&lt;P&gt;var i = 0&lt;/P&gt;&lt;P&gt;var featureDataPoint = FeatureSetByPortalItem(Portal('&lt;A href="https://gccountymi.maps.arcgis.com" target="_blank"&gt;https://gccountymi.maps.arcgis.com&lt;/A&gt;'), '9396510de4514d27a344ad12dbecdbfa', 0, ['TOT_PRJ_CO','BNDRY_DESC','JOB_OPERT_'], false);&lt;/P&gt;&lt;P&gt;console(count(featureDataPoint))&lt;/P&gt;&lt;P&gt;var featureDataLine = FeatureSetByPortalItem(Portal('&lt;A href="https://gccountymi.maps.arcgis.com" target="_blank"&gt;https://gccountymi.maps.arcgis.com&lt;/A&gt;'), '9396510de4514d27a344ad12dbecdbfa', 1, ['TOT_PRJ_CO', 'BNDRY_DESC','JOB_OPERT_'], false);&lt;/P&gt;&lt;P&gt;console(count(featureDataLine))&lt;/P&gt;&lt;P&gt;for(var a in featureDataPoint){&lt;BR /&gt;feat_arr[i] = {attributes: {total_cost: a.TOT_PRJ_CO, mpo: a.BNDRY_DESC, status: a.JOB_OPERT_}}&lt;BR /&gt;i++&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;console(count(featureDataPoint))&lt;/P&gt;&lt;P&gt;for(var b in featureDataLine){&lt;BR /&gt;feat_arr[i] = {attributes: {total_cost: b.TOT_PRJ_CO, mpo: b.BNDRY_DESC, status: b.JOB_OPERT_}}&lt;BR /&gt;i++&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;console(count(featureDataLine))&lt;/P&gt;&lt;P&gt;var combinedDict = {&lt;BR /&gt;fields: [{ name: "total_cost", type: "esriFieldTypeInteger"},&lt;BR /&gt;{ name: "mpo", type: "esriFieldTypeString"},&lt;BR /&gt;{ name: "status", type: "esriFieldTypeString"}],&lt;BR /&gt;geometryType: "",&lt;BR /&gt;features: feat_arr,&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var newSet = FeatureSet(Text(combinedDict))&lt;/P&gt;&lt;P&gt;console(count(newSet))&lt;/P&gt;&lt;P&gt;return newSet&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Console messages showing the counts.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KenKoleda_0-1631221223596.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22701i248EDCB03ECA9B96/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KenKoleda_0-1631221223596.png" alt="KenKoleda_0-1631221223596.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Sep 2021 21:01:18 GMT</pubDate>
    <dc:creator>KenKoleda</dc:creator>
    <dc:date>2021-09-09T21:01:18Z</dc:date>
    <item>
      <title>How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1094912#M5015</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to combine data from two featuresets that are 1) hosted by someone else 2) of different geometries.&lt;/P&gt;&lt;P&gt;They contain project information.&amp;nbsp; Projects in one layer are lines, the other layer is points.&amp;nbsp; Each has an attribute representing total project cost.&amp;nbsp;&amp;nbsp; I can access each featureset, but cannot figure out how to essentially merge together the attribute data for display in say an indicator or some other widget.&amp;nbsp; I do not need the geometry.&lt;/P&gt;&lt;P&gt;I created a data expression as the data source as shown below.&lt;/P&gt;&lt;P&gt;It seems like I could use FeatureSet(defintiion) where the definition is JSON, but I am not finding good examples of the format needed or how to go from one to the other.&lt;/P&gt;&lt;P&gt;Any pointers to documentation, examples or suggestions appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;==================&lt;/P&gt;&lt;P&gt;var featureDataPoint = FeatureSetByPortalItem(Portal('&lt;A href="https://gccountymi.maps.arcgis.com" target="_blank"&gt;https://gccountymi.maps.arcgis.com&lt;/A&gt;'), 'd600a66fe6ac48a098cb94a36d97a48b', 3);&lt;BR /&gt;var featureDataLine = FeatureSetByPortalItem(Portal('&lt;A href="https://gccountymi.maps.arcgis.com" target="_blank"&gt;https://gccountymi.maps.arcgis.com&lt;/A&gt;'), 'd600a66fe6ac48a098cb94a36d97a48b', 4);&lt;/P&gt;&lt;P&gt;//TOT_PRJ_COST&lt;BR /&gt;// need to create a featureSet with TOT_PRJ_COST from two featuresets and put in 'featureData'&lt;/P&gt;&lt;P&gt;return featureData&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 14:16:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1094912#M5015</guid>
      <dc:creator>KenKoleda</dc:creator>
      <dc:date>2021-09-02T14:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1094917#M5016</link>
      <description>&lt;P&gt;Do the lines and points have a spatial relationship? Or is there an attribute they have in common? Merging the attributes of these is going to depend a lot on the specifics.&lt;/P&gt;&lt;P&gt;Or do you simply want one row in your output for each feature in both inputs? That would be easier.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 14:26:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1094917#M5016</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-09-02T14:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1095026#M5018</link>
      <description>&lt;P&gt;No spatial or other relationship, I just need to append their attributes.&amp;nbsp; I was presuming that the featureset can be just a table since I have dashboards for COVID that are reading CSVs and populating indicators and graphs.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 17:41:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1095026#M5018</guid>
      <dc:creator>KenKoleda</dc:creator>
      <dc:date>2021-09-02T17:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1095035#M5019</link>
      <description>&lt;P&gt;Well, that is much simpler. Try something like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var feat_arr = []

var i = 0

var featureDataPoint = FeatureSetByPortalItem(Portal('https://gccountymi.maps.arcgis.com'), 'd600a66fe6ac48a098cb94a36d97a48b', 3, ['TOT_PRJ_COST'], false);

var featureDataLine = FeatureSetByPortalItem(Portal('https://gccountymi.maps.arcgis.com'), 'd600a66fe6ac48a098cb94a36d97a48b', 4, ['TOT_PRJ_COST'], false);

for(var a in featureDataPoint){
    feat_arr[i] = {attributes: {total_cost: a.TOT_PRJ_COST}}
    i++
}

for(var b in featureDataLine){
    feat_arr[i] = {attributes: {total_cost: b.TOT_PRJ_COST}}
    i++
}

var combinedDict = {
  fields: [{ name: "total_cost", type: "esriFieldTypeInteger"}],
  geometryType: "",
  features: feat_arr,
};

FeatureSet(Text(combinedDict))&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1630606102844.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22317i69222C89CFBA24ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1630606102844.png" alt="jcarlson_0-1630606102844.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;By the way, I specified only the total cost attribute in the &lt;STRONG&gt;FeatureSet&lt;/STRONG&gt; functions and explicitly stated &lt;STRONG&gt;false&lt;/STRONG&gt; to exclude the geometry. That should help your expression's performance some.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 18:09:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1095035#M5019</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-09-02T18:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1095098#M5021</link>
      <description>&lt;P&gt;This worked!&amp;nbsp; I did need to add two more fields to read them from the data source and then output to the featureset, but was able to figure that out from the example you provided!&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 20:11:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1095098#M5021</guid>
      <dc:creator>KenKoleda</dc:creator>
      <dc:date>2021-09-02T20:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1096970#M5055</link>
      <description>&lt;P&gt;Hello, as it turned out the solution appears not to be 100% correct and I am at a loss to figure out why.&lt;/P&gt;&lt;P&gt;It seems that each array contains less features that the source featureclass and&amp;nbsp; the combined set has still fewer features.&lt;/P&gt;&lt;P&gt;For example, I have 3197 points.&amp;nbsp; immediately after created the 'featureDataPoint is shows 3095 -- as reported via a console message using the count() function.&lt;/P&gt;&lt;P&gt;The total number of the two layers combined starts at 7011 and in the arrays are 6855 and in the final "newSet" is 5303&lt;/P&gt;&lt;P&gt;Here is my current code:&lt;/P&gt;&lt;P&gt;// Write an expression that returns a FeatureSet.&lt;BR /&gt;// Documentation: &lt;A href="https://arcg.is/3c419TD" target="_blank"&gt;https://arcg.is/3c419TD&lt;/A&gt;&lt;BR /&gt;// Samples: &lt;A href="https://arcg.is/38SEWWz" target="_blank"&gt;https://arcg.is/38SEWWz&lt;/A&gt;&lt;/P&gt;&lt;P&gt;var feat_arr = []&lt;/P&gt;&lt;P&gt;var i = 0&lt;/P&gt;&lt;P&gt;var featureDataPoint = FeatureSetByPortalItem(Portal('&lt;A href="https://gccountymi.maps.arcgis.com" target="_blank"&gt;https://gccountymi.maps.arcgis.com&lt;/A&gt;'), '9396510de4514d27a344ad12dbecdbfa', 0, ['TOT_PRJ_CO','BNDRY_DESC','JOB_OPERT_'], false);&lt;/P&gt;&lt;P&gt;console(count(featureDataPoint))&lt;/P&gt;&lt;P&gt;var featureDataLine = FeatureSetByPortalItem(Portal('&lt;A href="https://gccountymi.maps.arcgis.com" target="_blank"&gt;https://gccountymi.maps.arcgis.com&lt;/A&gt;'), '9396510de4514d27a344ad12dbecdbfa', 1, ['TOT_PRJ_CO', 'BNDRY_DESC','JOB_OPERT_'], false);&lt;/P&gt;&lt;P&gt;console(count(featureDataLine))&lt;/P&gt;&lt;P&gt;for(var a in featureDataPoint){&lt;BR /&gt;feat_arr[i] = {attributes: {total_cost: a.TOT_PRJ_CO, mpo: a.BNDRY_DESC, status: a.JOB_OPERT_}}&lt;BR /&gt;i++&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;console(count(featureDataPoint))&lt;/P&gt;&lt;P&gt;for(var b in featureDataLine){&lt;BR /&gt;feat_arr[i] = {attributes: {total_cost: b.TOT_PRJ_CO, mpo: b.BNDRY_DESC, status: b.JOB_OPERT_}}&lt;BR /&gt;i++&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;console(count(featureDataLine))&lt;/P&gt;&lt;P&gt;var combinedDict = {&lt;BR /&gt;fields: [{ name: "total_cost", type: "esriFieldTypeInteger"},&lt;BR /&gt;{ name: "mpo", type: "esriFieldTypeString"},&lt;BR /&gt;{ name: "status", type: "esriFieldTypeString"}],&lt;BR /&gt;geometryType: "",&lt;BR /&gt;features: feat_arr,&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var newSet = FeatureSet(Text(combinedDict))&lt;/P&gt;&lt;P&gt;console(count(newSet))&lt;/P&gt;&lt;P&gt;return newSet&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Console messages showing the counts.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KenKoleda_0-1631221223596.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22701i248EDCB03ECA9B96/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KenKoleda_0-1631221223596.png" alt="KenKoleda_0-1631221223596.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 21:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1096970#M5055</guid>
      <dc:creator>KenKoleda</dc:creator>
      <dc:date>2021-09-09T21:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1097020#M5056</link>
      <description>&lt;P&gt;Well, this is certainly strange. When I add console messages to my own expression, it returns the correct totals for the FeatureSets and layers, but the FeatureSet at the end is smaller.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_3-1631223329813.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22721iE24EC3BA510593AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_3-1631223329813.png" alt="jcarlson_3-1631223329813.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I can't account for the different totals you're getting in your FeatureSets, but I did dig into why the FeatureSet has different outputs. Take a look here at the output, and you'll see that the ID columns (I added the variable &lt;EM&gt;i&lt;/EM&gt; as an integer field for testing) skip some values. What's going on here?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_4-1631223360520.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22722i5E538AD6C15C674D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_4-1631223360520.png" alt="jcarlson_4-1631223360520.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We can see that 81-84 are missing, so I'll call up a few of them from&amp;nbsp;&lt;STRONG&gt;feat_arr&lt;/STRONG&gt; to see what their values are.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_5-1631223661227.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22723i919FAB096899938B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_5-1631223661227.png" alt="jcarlson_5-1631223661227.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The culprit: &lt;EM&gt;floating point values&lt;/EM&gt;. I didn't anticipate these based on a quick sample of the input data, but odds are when it hits those floats and tries inserting them into our defined integer field, it errors out and skips.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H4&gt;100% solutions (pick one):&lt;/H4&gt;&lt;OL&gt;&lt;LI&gt;Round off the values before inserting them into the array, i.e., &lt;STRONG&gt;Round(a.TOT_PRJ_CO)&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Change the field to a floating point type&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I like integers myself, so here's the output with a rounding function in the loop.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_6-1631224122097.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22726iD1B816FA67863A2B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_6-1631224122097.png" alt="jcarlson_6-1631224122097.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Again, I'm still not sure why your FeatureSets are reading out a different total. I even get the correct totals when including the additional fields.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 21:51:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1097020#M5056</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-09-09T21:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1097157#M5057</link>
      <description>&lt;P&gt;Once again, you came to the rescue!&amp;nbsp; The code is now working 100% I believe.&lt;/P&gt;&lt;P&gt;We are in fact getting the correct record count.&amp;nbsp; It was my error thinking we were not.&amp;nbsp; The issue was that we have been trying to access a server that is super slow and intermittent.&amp;nbsp; I had copied the data to our AGO, but it was an older version because the other site is SO slow I would not even download both files yesterday.&amp;nbsp; The difference in the files account for the apparent different count.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, we just gotta hope that the hosting entity gets their server straightened out so we can access it directly.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 13:02:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1097157#M5057</guid>
      <dc:creator>KenKoleda</dc:creator>
      <dc:date>2021-09-10T13:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a featureset from two other featuresets</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1098569#M5092</link>
      <description>&lt;P&gt;We did this by creating a database view that combined our Primavera and GIS data.&amp;nbsp; It updates automatically&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 17:21:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/how-to-create-a-featureset-from-two-other/m-p/1098569#M5092</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2021-09-15T17:21:28Z</dc:date>
    </item>
  </channel>
</rss>

