<?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 Feature Count limit in a for loop? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/feature-count-limit-in-a-for-loop/m-p/1347324#M6821</link>
    <description>&lt;P&gt;Update: I got an error return while exploring an unrelated issue. &amp;nbsp;It appears there is a recordCount parameter being passed that I did not set.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShaunLangley_1-1699474427069.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85406iCF000EC2370FC120/image-size/large?v=v2&amp;amp;px=999" role="button" title="ShaunLangley_1-1699474427069.png" alt="ShaunLangley_1-1699474427069.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The default on the feature service is 10k records.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShaunLangley_2-1699474490892.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85407iD25894C72AA6C31A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShaunLangley_2-1699474490892.png" alt="ShaunLangley_2-1699474490892.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas how to override this in my expression?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Post&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm running into some strange behavior with my data expression. &amp;nbsp;I'm trying to preprocess some data before it goes to my dashboard to reduce the data load. &amp;nbsp;However, I'm only now realizing that the for loop in my code (shown below) is terminating after 1000 records when there are more than 166k records in the input dataset. &amp;nbsp;I thought it might be a limit on the service, but it appears that the service is set to 10k. &amp;nbsp;Certainly l could foresee an issue hitting that limit, but in this case, the loop is terminating even before that point. &amp;nbsp;Does anyone see an issue in my code or has experienced this in their own work?&lt;/P&gt;&lt;P&gt;Context: I'm reading data from an ArcGIS Monitor feature service. &amp;nbsp;There is too much data for Dashboard to have to parse through so I'm trying to reduce the volume. &amp;nbsp;Note: I've masked the portal url and id due to an NDA with my client. It shouldn't affect readability.&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;// Reference layer using the FeatureSetByPortalItem() function. 
var portal = Portal('https://---.com/arcgis')
var collectionId = '--'
var fs = FeatureSetByPortalItem(
    portal, 
    collectionId, 
    5, 
    ['component_id', 'name', 'value', 'observed_at']
);

// return only records within the last day, the max time period supported
var time_delta = DateAdd(Now(), -24, 'hours');
var filtered = OrderBy(
    Filter(fs, "observed_at &amp;gt; _delta and name = 'Requests Received'"),
    "component_id asc"
)

// get services table to pull names for the component ids
var svs = FeatureSetByPortalItem(
    portal, 
    collectionId, 
    4, 
    ['*'], 
    false
);

// build the output schema to write to
var output = {
    fields: [
        { name: "component_id", type: "esriFieldTypeInteger" },
        { name: "component", type: "esriFieldTypeString" },
        { name: "metric", type: "esriFieldTypeString" },
        { name: "observed_at", type: "esriFieldTypeDate" },
        { name: "total", type: "esriFieldTypeInteger" }
    ],
    'geometryType': '',
    'features': []
};

// loop over each record in the filtered dataset and write the name and metrics to the output
var feat;
var featureCount
for (var a in filtered) {
    //var s = First(Filter(svs, 'id = ' + a.component_id))
    feat = {
        attributes: {
           component_id: a.component_id,
            component: '',
            metric: a.name,
            observed_at: Number(a.observed_at),
            total: a.value
        }
    }
    Push(output.features, feat)
}


var fs = FeatureSet(Text(output))
var grouped = GroupBy(
    fs, 
    ["component_id", "component", "observed_at"],
    { name: "Total", expression: "total", statistic: "SUM" }
)

Console("input count: " + Count(filtered))
Console("processed count: " + featureCount)
Console("output count: " + Count(fs))
Console("services count: " +Count(svs))
Console("grouped count: " + Count(grouped))

return grouped
//return filtered&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: here is the output from the console showing the counts&lt;/P&gt;&lt;P&gt;input count: 166894&lt;BR /&gt;processed count: 1000&lt;BR /&gt;output count: 1000&lt;BR /&gt;services count: 94&lt;BR /&gt;grouped count: 1000&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2023 20:15:03 GMT</pubDate>
    <dc:creator>ShaunLangley</dc:creator>
    <dc:date>2023-11-08T20:15:03Z</dc:date>
    <item>
      <title>Feature Count limit in a for loop?</title>
      <link>https://community.esri.com/t5/developers-questions/feature-count-limit-in-a-for-loop/m-p/1347324#M6821</link>
      <description>&lt;P&gt;Update: I got an error return while exploring an unrelated issue. &amp;nbsp;It appears there is a recordCount parameter being passed that I did not set.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShaunLangley_1-1699474427069.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85406iCF000EC2370FC120/image-size/large?v=v2&amp;amp;px=999" role="button" title="ShaunLangley_1-1699474427069.png" alt="ShaunLangley_1-1699474427069.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The default on the feature service is 10k records.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShaunLangley_2-1699474490892.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85407iD25894C72AA6C31A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShaunLangley_2-1699474490892.png" alt="ShaunLangley_2-1699474490892.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas how to override this in my expression?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Post&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm running into some strange behavior with my data expression. &amp;nbsp;I'm trying to preprocess some data before it goes to my dashboard to reduce the data load. &amp;nbsp;However, I'm only now realizing that the for loop in my code (shown below) is terminating after 1000 records when there are more than 166k records in the input dataset. &amp;nbsp;I thought it might be a limit on the service, but it appears that the service is set to 10k. &amp;nbsp;Certainly l could foresee an issue hitting that limit, but in this case, the loop is terminating even before that point. &amp;nbsp;Does anyone see an issue in my code or has experienced this in their own work?&lt;/P&gt;&lt;P&gt;Context: I'm reading data from an ArcGIS Monitor feature service. &amp;nbsp;There is too much data for Dashboard to have to parse through so I'm trying to reduce the volume. &amp;nbsp;Note: I've masked the portal url and id due to an NDA with my client. It shouldn't affect readability.&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;// Reference layer using the FeatureSetByPortalItem() function. 
var portal = Portal('https://---.com/arcgis')
var collectionId = '--'
var fs = FeatureSetByPortalItem(
    portal, 
    collectionId, 
    5, 
    ['component_id', 'name', 'value', 'observed_at']
);

// return only records within the last day, the max time period supported
var time_delta = DateAdd(Now(), -24, 'hours');
var filtered = OrderBy(
    Filter(fs, "observed_at &amp;gt; _delta and name = 'Requests Received'"),
    "component_id asc"
)

// get services table to pull names for the component ids
var svs = FeatureSetByPortalItem(
    portal, 
    collectionId, 
    4, 
    ['*'], 
    false
);

// build the output schema to write to
var output = {
    fields: [
        { name: "component_id", type: "esriFieldTypeInteger" },
        { name: "component", type: "esriFieldTypeString" },
        { name: "metric", type: "esriFieldTypeString" },
        { name: "observed_at", type: "esriFieldTypeDate" },
        { name: "total", type: "esriFieldTypeInteger" }
    ],
    'geometryType': '',
    'features': []
};

// loop over each record in the filtered dataset and write the name and metrics to the output
var feat;
var featureCount
for (var a in filtered) {
    //var s = First(Filter(svs, 'id = ' + a.component_id))
    feat = {
        attributes: {
           component_id: a.component_id,
            component: '',
            metric: a.name,
            observed_at: Number(a.observed_at),
            total: a.value
        }
    }
    Push(output.features, feat)
}


var fs = FeatureSet(Text(output))
var grouped = GroupBy(
    fs, 
    ["component_id", "component", "observed_at"],
    { name: "Total", expression: "total", statistic: "SUM" }
)

Console("input count: " + Count(filtered))
Console("processed count: " + featureCount)
Console("output count: " + Count(fs))
Console("services count: " +Count(svs))
Console("grouped count: " + Count(grouped))

return grouped
//return filtered&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: here is the output from the console showing the counts&lt;/P&gt;&lt;P&gt;input count: 166894&lt;BR /&gt;processed count: 1000&lt;BR /&gt;output count: 1000&lt;BR /&gt;services count: 94&lt;BR /&gt;grouped count: 1000&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 20:15:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/feature-count-limit-in-a-for-loop/m-p/1347324#M6821</guid>
      <dc:creator>ShaunLangley</dc:creator>
      <dc:date>2023-11-08T20:15:03Z</dc:date>
    </item>
  </channel>
</rss>

