<?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: Help with a expression to count features only where criteria is matched in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1681046#M22305</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That code did not work. it kept giving me in valid syntax error. I was able spring board off of it and managed to&amp;nbsp; get something that worked:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Count selected meters where CRITICAL = 1

var fs = $dataSources["dataSource_1-19bc841fd0e-layer-7"].selectedFeatures;

// If nothing is selected, show 0
if (IsEmpty(fs)) {
  return 0;
}

// Count only critical meters within the selection
return Count(Filter(fs, "CRITICAL = 1"));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know of any where I can learn the basic syntax rules of &lt;SPAN&gt;arcade? knowing the formal rules would be helpful in trying to compile code for various things.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jan 2026 13:28:47 GMT</pubDate>
    <dc:creator>Laura_m_Conner</dc:creator>
    <dc:date>2026-01-30T13:28:47Z</dc:date>
    <item>
      <title>Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1678466#M22167</link>
      <description>&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;In Arc GIS online, in an experience i am building i have text box that i want to&amp;nbsp; show the count&amp;nbsp; of all selected data where a "field" matches a "value". I got the text box set up&amp;nbsp; linked to the data. I am adding the dynamic text. In the expression dialog window what expression in the expression box do I put? so far AI and my own attempts have failed. Is this even posable to do in this manner? If not what&amp;nbsp; is there an approach I use can that avoids having to making a view and filtering it on the field?&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jan 2026 21:04:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1678466#M22167</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2026-01-16T21:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1678693#M22178</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/432404"&gt;@Laura_m_Conner&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Please use Arcade in Experience Builder. The help link is here:&amp;nbsp;&lt;A href="https://doc.arcgis.com/en/experience-builder/latest/configure-widgets/advanced-formatting.htm#ESRI_SECTION1_573128B984C64FBA9FEC507C66383145" target="_blank"&gt;https://doc.arcgis.com/en/experience-builder/latest/configure-widgets/advanced-formatting.htm#ESRI_SECTION1_573128B984C64FBA9FEC507C66383145&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ke&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jan 2026 02:36:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1678693#M22178</guid>
      <dc:creator>Ke_Xu</dc:creator>
      <dc:date>2026-01-20T02:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1678731#M22180</link>
      <description>&lt;P&gt;That is what I am trying to do. The problem is I can not figure out the syntax for it.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jan 2026 13:24:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1678731#M22180</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2026-01-20T13:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1678751#M22182</link>
      <description>&lt;P&gt;This code should work. You'll have to replace the datasource ID with your own and supply the correct field name in the sql statement.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var ds = $dataSources["dataSource_1-19123c9cd36-layer-2"];
var layer = $dataSources["dataSource_1-19123c9cd36-layer-2"].layer;
var sql = "yourField = value" //or "yourField = 'value'" if it's a string
var filteredLayer = Filter(layer, sql)
var output = Count(filteredLayer)

return {
  value: output,
  text: {
    // size: 14,
    // color: 'rgb(0, 0, 255)',
    // bold: true,
    // italic: false,
    // underline: false,
    // strike: false
  },
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;This is what it looks like in while editing the Text widget. "Feature Count"&amp;nbsp;is the name of the Arcade script.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2026-01-20_10-06-40.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/146965i5126E39A6A8717C6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2026-01-20_10-06-40.PNG" alt="2026-01-20_10-06-40.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And this is what the final result is&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2026-01-20_10-06-54.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/146966iFDF0BF46788A3B61/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2026-01-20_10-06-54.PNG" alt="2026-01-20_10-06-54.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jan 2026 15:08:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1678751#M22182</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2026-01-20T15:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1679580#M22231</link>
      <description>&lt;P&gt;all,&lt;/P&gt;&lt;P&gt;sorry for the delay. I am bouncing between projects.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok I have gotten in to the arcade widow in the text box to past my code. your code is giving me an invalid expression warning when i try to modify it. How do i find my&amp;nbsp;&lt;SPAN&gt;datasource ID for the layer i want to use?&amp;nbsp; also on this note I am going to try and make a arc GIS solution out if it. the idea is for people to change in their data layer for the template data layer i have set up. is this kind of data source connection going to cause it to brake when the substation happens?&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i got the flowing code to return true / false if a&amp;nbsp; feature matching&amp;nbsp; the criteria is selected but cant figure out how to modify it return the count. can that be done? the code is:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;function getFilteredFeatureSet(ds) {
var result = ds.layer;
var queryParams = ds.queryParams;

// Leave selection logic unchanged
if (!IsEmpty(queryParams.where)) {
result = Filter(result, queryParams.where);
}

if (!IsEmpty(queryParams.geometry)) {
result = Intersects(result, queryParams.geometry);
}

// Filter to critical only
result = Filter(result, "criticalCustomer = 1");

return result;
}

// ds must be whatever Experience Builder is passing you for the selected-meter datasource.
// Keep your existing ds line here (do not change it).
// Example (yours will differ): var ds = $datastore["Meters"].asDynamicLayer();

var fs = getFilteredFeatureSet(ds);
return Count(fs);
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also resources on this would also be helpfull.&lt;/P&gt;&lt;P&gt;Laura&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jan 2026 16:18:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1679580#M22231</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2026-01-23T16:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1679640#M22233</link>
      <description>&lt;P&gt;Try this script&lt;/P&gt;&lt;LI-CODE lang="java"&gt;function getFilteredFeatureSet(ds) {
var result = ds.layer;
var queryParams = ds.queryParams;

// Leave selection logic unchanged
if (!IsEmpty(queryParams.where)) {
result = Filter(result, queryParams.where);
}

if (!IsEmpty(queryParams.geometry)) {
result = Intersects(result, queryParams.geometry);
}

// Filter to critical only
result = Filter(result, "criticalCustomer = 1");

return result;
}

// ds must be whatever Experience Builder is passing you for the selected-meter datasource.
// Keep your existing ds line here (do not change it).
// Example (yours will differ): var ds = $datastore["Meters"].asDynamicLayer();

var ds = 
var fs = getFilteredFeatureSet(ds);
return Count(fs);&lt;/LI-CODE&gt;&lt;P&gt;To get the correct layer, after you've connected the text box to your data, click edit, then the Arcade button. Put your cursor on line 24 after the =. On the side of the script editor is the Profile variable button. Click it, then click the arrow on right side of the $datasources line. Click the first line below that which has your datasource ID to add it to your script.&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6388173506112w822h540r378" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6388173506112" data-account="6161463677001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6161463677001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6388173506112w822h540r378');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.esri.com/t5/video/gallerypage/video-id/6388173506112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jan 2026 18:38:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1679640#M22233</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2026-01-23T18:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1679689#M22235</link>
      <description>&lt;P&gt;Thanks i try it as soon as I get a chance&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jan 2026 20:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1679689#M22235</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2026-01-23T20:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1681046#M22305</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That code did not work. it kept giving me in valid syntax error. I was able spring board off of it and managed to&amp;nbsp; get something that worked:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Count selected meters where CRITICAL = 1

var fs = $dataSources["dataSource_1-19bc841fd0e-layer-7"].selectedFeatures;

// If nothing is selected, show 0
if (IsEmpty(fs)) {
  return 0;
}

// Count only critical meters within the selection
return Count(Filter(fs, "CRITICAL = 1"));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know of any where I can learn the basic syntax rules of &lt;SPAN&gt;arcade? knowing the formal rules would be helpful in trying to compile code for various things.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jan 2026 13:28:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1681046#M22305</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2026-01-30T13:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1681058#M22307</link>
      <description>&lt;P&gt;Start with the &lt;A href="https://developers.arcgis.com/arcade/" target="_self"&gt;Arcade documentation&lt;/A&gt;, which contains lots of information about how to use the language, especially in the Language features section.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jan 2026 14:00:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1681058#M22307</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2026-01-30T14:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a expression to count features only where criteria is matched</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1681097#M22309</link>
      <description>&lt;P&gt;Thanks Will Do.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jan 2026 16:01:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/help-with-a-expression-to-count-features-only/m-p/1681097#M22309</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2026-01-30T16:01:08Z</dc:date>
    </item>
  </channel>
</rss>

