<?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: Creating a Serial Chart in Dashboard using  Arcade 'count' on multiple fields in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1521354#M60829</link>
    <description>&lt;P&gt;Just tried it again this morning and it's working! Exactly what I was after, thanks Josh!&lt;/P&gt;</description>
    <pubDate>Wed, 14 Aug 2024 09:40:53 GMT</pubDate>
    <dc:creator>ttw_marine</dc:creator>
    <dc:date>2024-08-14T09:40:53Z</dc:date>
    <item>
      <title>Creating a Serial Chart in Dashboard using  Arcade 'count' on multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1515410#M60669</link>
      <description>&lt;P&gt;I want to create a Serial Chart for a Dashboard where each column corresponds to a field in a single feature class. I think this needs to be done with Arcade. I've been trying to write something but not very familiar with Arcade. Does anyone know what the code might look like?&lt;/P&gt;&lt;P&gt;There are 4 fields, I would like each to be a bar on the chart.&lt;/P&gt;&lt;P&gt;Each field's entries are equal to either "YES" or "NO".&lt;/P&gt;&lt;P&gt;For each bar &amp;amp; field, I would like a count of all the "YES" entries and all the "NO" entries.&lt;/P&gt;&lt;P&gt;I would like this represented as a stacked bar for each field.&lt;/P&gt;&lt;P&gt;I have included an image giving a very rough example. Any ideas very welcome, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 11:34:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1515410#M60669</guid>
      <dc:creator>ttw_marine</dc:creator>
      <dc:date>2024-08-06T11:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Serial Chart in Dashboard using  Arcade 'count' on multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1515501#M60677</link>
      <description>&lt;P&gt;Yes, unfortunately a chart's "fields" option only works for numeric fields. Summing multiple fields is easy enough in a single GroupBy expression. But getting the yes and no sums to stack, that's another thing.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1722953724844.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111715i957B269AA4450931/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1722953724844.png" alt="jcarlson_0-1722953724844.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You still don't need to do a loop, but GroupBy only gets us 95% of the way there. Taken those totals and building our own FeatureSet does the trick.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(
  Portal('your portal url'),
  'itemid of service',
  0, // layer index
  ['A', 'B', 'C', 'D'],
  false
)

var g = First(GroupBy(
    fs,
    {name: 'result', expression: '1'},
    [
        {name: 'AY', expression: "CASE WHEN A = 'Y' THEN 1 ELSE 0 END", statistic: 'SUM'},
        {name: 'AN', expression: "CASE WHEN A = 'N' THEN 1 ELSE 0 END", statistic: 'SUM'},
        {name: 'BY', expression: "CASE WHEN B = 'Y' THEN 1 ELSE 0 END", statistic: 'SUM'},
        {name: 'BN', expression: "CASE WHEN B = 'N' THEN 1 ELSE 0 END", statistic: 'SUM'},
        {name: 'CY', expression: "CASE WHEN C = 'Y' THEN 1 ELSE 0 END", statistic: 'SUM'},
        {name: 'CN', expression: "CASE WHEN C = 'N' THEN 1 ELSE 0 END", statistic: 'SUM'},
        {name: 'DY', expression: "CASE WHEN D = 'Y' THEN 1 ELSE 0 END", statistic: 'SUM'},
        {name: 'DN', expression: "CASE WHEN D = 'N' THEN 1 ELSE 0 END", statistic: 'SUM'},
    ]
))

return FeatureSet(Text({
    fields: [
        {name: 'letter', type: 'esriFieldTypeString'},
        {name: 'response', type: 'esriFieldTypeString'},
        {name: 'count', type: 'esriFieldTypeInteger'},
    ],
    geometryType: '',
    features: [
        {attributes: {letter: 'A', response: 'Y', count: g['AY']}},
        {attributes: {letter: 'A', response: 'N', count: g['AN']}},
        {attributes: {letter: 'B', response: 'Y', count: g['BY']}},
        {attributes: {letter: 'B', response: 'N', count: g['BN']}},
        {attributes: {letter: 'C', response: 'Y', count: g['CY']}},
        {attributes: {letter: 'C', response: 'N', count: g['CN']}},
        {attributes: {letter: 'D', response: 'Y', count: g['DY']}},
        {attributes: {letter: 'D', response: 'N', count: g['DN']}},
    ]
}))&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1722954766457.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111718i49FADA4979A55EA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1722954766457.png" alt="jcarlson_1-1722954766457.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 14:33:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1515501#M60677</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-08-06T14:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Serial Chart in Dashboard using  Arcade 'count' on multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1520603#M60807</link>
      <description>&lt;P&gt;Thank you Josh this looks great! Really appreciate your help with this.&lt;/P&gt;&lt;P&gt;I've put in this code and substituted the actual layer &amp;amp; field names, but when I run the script I get the following error: "&lt;SPAN&gt;Test execution error: Invalid variable assignment.. Verify test data.". Not sure if I've inputted anything in wrong, or perhaps its an issue with the 'portal' URL?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ttw_marine_1-1723562531206.png" style="width: 1257px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/112218iC8D6DC1058E47EA4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ttw_marine_1-1723562531206.png" alt="ttw_marine_1-1723562531206.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 15:23:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1520603#M60807</guid>
      <dc:creator>ttw_marine</dc:creator>
      <dc:date>2024-08-13T15:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Serial Chart in Dashboard using  Arcade 'count' on multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1521354#M60829</link>
      <description>&lt;P&gt;Just tried it again this morning and it's working! Exactly what I was after, thanks Josh!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 09:40:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/creating-a-serial-chart-in-dashboard-using-arcade/m-p/1521354#M60829</guid>
      <dc:creator>ttw_marine</dc:creator>
      <dc:date>2024-08-14T09:40:53Z</dc:date>
    </item>
  </channel>
</rss>

