<?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: Trying to create a very simple Arcade data expression in Dashboards but nothing works in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639038#M65848</link>
    <description>&lt;P&gt;Now I am just trying to even see if I can load a layer at all. Nothing is working. I tried this and still no work:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Attempt to load your map layer and count features
var fs = FeatureSetByName($map, "Inventory by Underutilization Rank", ["OBJECTID"], false);

// Count features
var total = Count(fs);

// Return result as one row
var features = [{
  attributes: {
    total_count: total
  }
}];

var schema = {
  fields: [
    { name: "total_count", type: "esriFieldTypeInteger" }
  ]
};

return FeatureSet(Text(features), schema);&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 05 Aug 2025 01:31:36 GMT</pubDate>
    <dc:creator>BarrettLewis1</dc:creator>
    <dc:date>2025-08-05T01:31:36Z</dc:date>
    <item>
      <title>Trying to create a very simple Arcade data expression in Dashboards but nothing works</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1638683#M65841</link>
      <description>&lt;P&gt;I am trying to create breaks within a certain data field so that, within a Dashboard, a can have a bar chart that shows those bins. I want to do an Arcade expression rather than adjusting the data in a separate field, because these breaks are subject to change as the Dashboard is reviewed. To me this seems like it should be very easy, but nothing works and most frustratingly, there doesn't seem to be a way to actually see what isn't working, as you could on any IDE. Esri documentation is also, as usual for them, terrible. So I am hoping someone can help me. So far I have been working through ChatGPT (I know, I know...) to come up with something.&lt;/P&gt;&lt;P&gt;All I am trying to do is that a field "Taxlot_Acres", which as can be surmised by the name, is the area in acres of a taxlot. I want a bar chart attached to the layer that shows count of taxlots in each bin. This bar chart will dynamically reflect other filters on the layer. Here is what I have come up with so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Connect to your hosted feature layer by portal item ID and layer index
var portal = Portal("https://www.arcgis.com");

var fs = FeatureSetByPortalItem(
    portal,
    "012345ABCEDF6789",  // Your item ID
    2,                                   // Layer index
    ["Taxlot_Acres"],                    // Only bring in needed field
    false                                // Exclude geometry (faster)
);

// Define output schema
var schema = {
  fields: [
    { name: "bin", type: "esriFieldTypeString" },
    { name: "count", type: "esriFieldTypeInteger" }
  ]
};

// Initialize bin counters
var bins = {
  "&amp;lt;1": 0,
  "1–4": 0,
  "5–9": 0,
  "10–24": 0,
  "25+": 0
};

// Loop through features and apply binning logic
for (var f in fs) {
  var acres = f["Taxlot_Acres"];
  if (acres == null) { continue; }

  if (acres &amp;lt; 1) {
    bins["&amp;lt;1"] += 1;
  } else if (acres &amp;lt; 5) {
    bins["1–4"] += 1;
  } else if (acres &amp;lt; 10) {
    bins["5–9"] += 1;
  } else if (acres &amp;lt; 25) {
    bins["10–24"] += 1;
  } else {
    bins["25+"] += 1;
  }
}

// Convert dictionary to FeatureSet
var output = [];

for (var b in bins) {
  Push(output, {
    attributes: {
      bin: b,
      count: bins[b]
    }
  });
}

return FeatureSet(Text(output), schema);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I feel like I am&amp;nbsp;&lt;EM&gt;almost&lt;/EM&gt; there, though which GPT and Esri's lack of quality documentation, can't be sure of that. Can anyone advise? I would be so grateful.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 02:05:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1638683#M65841</guid>
      <dc:creator>BarrettLewis1</dc:creator>
      <dc:date>2025-08-04T02:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a very simple Arcade data expression in Dashboards but nothing works</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1638792#M65842</link>
      <description>&lt;P&gt;This should work&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Connect to your hosted feature layer by portal item ID and layer index
var portal = Portal("https://www.arcgis.com");

var fs = FeatureSetByPortalItem(
    portal,
    "012345ABCEDF6789",  // Your item ID
    2,                                   // Layer index
    ["Taxlot_Acres"],                    // Only bring in needed field
    false                                // Exclude geometry (faster)
);

// Define output schema
var fields = [
  { name: "bin", type: "esriFieldTypeString" },
  { name: "count", type: "esriFieldTypeInteger" }
];

// Initialize bin counters
var bins = {
  "&amp;lt;1": 0,
  "1–4": 0,
  "5–9": 0,
  "10–24": 0,
  "25+": 0
};

for (var f in fs) {
  var acres = f["Taxlot_Acres"];
  if (IsEmpty(acres)) continue;
  When(
    acres &amp;lt; 1, bins["&amp;lt;1"] += 1,
    acres &amp;lt; 5, bins["1-5"] += 1,
    acres &amp;lt; 10, bins["5-9"] += 1,
    acres &amp;lt; 24, bins["10-24"] += 1,
    bins["25+"] += 1
  );
}

var features = [];
for (var b of bins) {
  Push(features, { attributes: { bin: b.key, count: b.value } });
}

return FeatureSet({ fields: fields, features: features });&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 04 Aug 2025 14:23:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1638792#M65842</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-08-04T14:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a very simple Arcade data expression in Dashboards but nothing works</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639034#M65846</link>
      <description>&lt;P&gt;Says it can't execute &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; I feel like I am doing something wrong I guess, but since Esri gives literally zero way to troubleshoot, I can't know...&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 01:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639034#M65846</guid>
      <dc:creator>BarrettLewis1</dc:creator>
      <dc:date>2025-08-05T01:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a very simple Arcade data expression in Dashboards but nothing works</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639037#M65847</link>
      <description>&lt;P&gt;Maybe doing this by featuresetname would be better? The layer is called&amp;nbsp;Inventory by Underutilization Rank. I should note that it is in a group layer, but I don't think that should matter&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 01:25:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639037#M65847</guid>
      <dc:creator>BarrettLewis1</dc:creator>
      <dc:date>2025-08-05T01:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a very simple Arcade data expression in Dashboards but nothing works</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639038#M65848</link>
      <description>&lt;P&gt;Now I am just trying to even see if I can load a layer at all. Nothing is working. I tried this and still no work:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Attempt to load your map layer and count features
var fs = FeatureSetByName($map, "Inventory by Underutilization Rank", ["OBJECTID"], false);

// Count features
var total = Count(fs);

// Return result as one row
var features = [{
  attributes: {
    total_count: total
  }
}];

var schema = {
  fields: [
    { name: "total_count", type: "esriFieldTypeInteger" }
  ]
};

return FeatureSet(Text(features), schema);&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Aug 2025 01:31:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639038#M65848</guid>
      <dc:creator>BarrettLewis1</dc:creator>
      <dc:date>2025-08-05T01:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a very simple Arcade data expression in Dashboards but nothing works</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639043#M65849</link>
      <description>&lt;P&gt;Well, I did finally get it to work, except I need the bins to dynamically change when filters are adjusted. Doesn't seem like it can do this, since when connecting it to a filter, the source field (the new bin category field in this case) can't connect with any target field in the map layers. It sounds like what I actually need is FeatureSetByName, but the issue is that the layer I am trying to attach is in a layer group, and for various reasons I need it to be in this grouping. Looks like FeatureSetByName doesn't work with layers in groups? I mean I can't get it to work with layers that are at the top level either but if this is true I should basically just stop now and just do it the normal way of calculating the bins in the data itself&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 02:26:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639043#M65849</guid>
      <dc:creator>BarrettLewis1</dc:creator>
      <dc:date>2025-08-05T02:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a very simple Arcade data expression in Dashboards but nothing works</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639187#M65851</link>
      <description>&lt;P&gt;You can trouble-shoot by using the &lt;A href="https://developers.arcgis.com/arcade/function-reference/debugging_functions/#console" target="_self"&gt;Console&lt;/A&gt; function and opening the Console tab after clicking "Run"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_6cc035.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137837i223E31854F203CB8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_6cc035.png" alt="Snag_6cc035.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The code would sometimes not run due to the bin names. If I changed them to this, it would run consistently&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var bins = {
  "a": 0,
  "b": 0,
  "c": 0,
  "d": 0,
  "e": 0
};

for (var f in fs) {
  var acres = f["Taxlot_Acres"];
  if (IsEmpty(acres)) continue;
  When(
    acres &amp;lt; 1, bins["a"] += 1,
    acres &amp;lt; 5, bins["b"] += 1,
    acres &amp;lt; 10, bins["c"] += 1,
    acres &amp;lt; 24, bins["d"] += 1,
    bins["e"] += 1
  );
}&lt;/LI-CODE&gt;&lt;P&gt;Then you would add the proper column names in the settings&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_7da4cb.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137845iC7AEC7862EE6E2B5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_7da4cb.png" alt="Snag_7da4cb.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 14:29:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/trying-to-create-a-very-simple-arcade-data/m-p/1639187#M65851</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-08-05T14:29:07Z</dc:date>
    </item>
  </channel>
</rss>

