<?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: Data Expression Null Values and Total Score in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1658019#M11538</link>
    <description>&lt;P&gt;Try something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
  name: 'TotalScore',
  expression: 'DefaultValue(Fingers1, 0) + DefaultValue(Fingers2, 0) + DefaultValue(Fingers3, 0) + DefaultValue(Barrel, 0) + DefaultValue(Serpentine, 0) + DefaultValue(AlleyDock, 0) + DefaultValue(StreetOffset, 0) + DefaultValue(Mailbox, 0) + DefaultValue(TirePush, 0) + DefaultValue(PlowDrop, 0)',
  statistic: 'SUM'
}&lt;/LI-CODE&gt;&lt;P&gt;This should set the value to 0 when the items are 'null'&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Oct 2025 14:21:30 GMT</pubDate>
    <dc:creator>Neal_t_k</dc:creator>
    <dc:date>2025-10-15T14:21:30Z</dc:date>
    <item>
      <title>Data Expression Null Values and Total Score</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1657882#M11535</link>
      <description>&lt;P&gt;I have the following dashboard data expression that looks at the results (view) of a Survey123 form and groups by Truck Number and does some basic addition. The Survey123 form displays fields based on a parameter URL. Each station, such as Fingers 1, Barrel, or Plow Drop, has a QR code that determines the fields that judges see. All of the results are populated into a single HFL. We can can calculate a Total Score field using ArcGIS Pro but we would like for this to be dynamic in a Dashboard.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var fs = FeaturesetByPortalItem(
    Portal("https://cohgov.maps.arcgis.com"), // your Portal's url
    "b8411078d5fc40c9b65012fe72e02a4d",      // the service id
    0,                                       // the sub-layer id
    ['Truck_No', 'Fingers1', 'Fingers2', 'Fingers3', 'Barrel', 'Serpentine', 'AlleyDock', 'StreetOffset', 'Mailbox', 'TirePush', 'PlowDrop'], // the fields you want to load
    false                                    // do you want to load geometries
    )

return GroupBy(fs, ['Truck_No'],
[
    {name: 'Fingers1score', expression: 'Fingers1', statistic: 'SUM' }, 
    {name: 'Fingers2score', expression: 'Fingers2', statistic: 'SUM' }, 
    {name: 'Fingers3score', expression: 'Fingers3', statistic: 'SUM' }, 
    {name: 'BarrelScore', expression: 'Barrel', statistic: 'SUM' }, 
    {name: 'SerpentineScore', expression: 'Serpentine', statistic: 'SUM' }, 
    {name: 'AlleyDockScore', expression: 'AlleyDock', statistic: 'SUM' }, 
    {name: 'StreetOffsetScore', expression: 'StreetOffset', statistic: 'SUM' }, 
    {name: 'MailboxScore', expression: 'Mailbox', statistic: 'SUM' }, 
    {name: 'TirePushScore', expression: 'TirePush', statistic: 'SUM' },
    {name: 'PlowDropscore', expression: 'PlowDrop', statistic: 'SUM' },

    // Add a new aggregation to sum all the score fields
    {
        name: 'TotalScore', 
        expression: 'Fingers1 + Fingers2 + Fingers3 + Barrel + Serpentine + AlleyDock + StreetOffset + Mailbox + TirePush + PlowDrop', 
        statistic: 'SUM' 
    }
]
)&lt;/PRE&gt;&lt;P&gt;The featureset looks decent.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndrewWilson1_1-1760486257962.png" style="width: 791px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141980i32AB5CCB1D7FA467/image-dimensions/791x149?v=v2" width="791" height="149" role="button" title="AndrewWilson1_1-1760486257962.png" alt="AndrewWilson1_1-1760486257962.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm running into two issues:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The summed null values should convert to 0.&lt;/LI&gt;&lt;LI&gt;TotalScore isn't working at all.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Any suggestions from the Esri Community?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 00:05:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1657882#M11535</guid>
      <dc:creator>AndrewWilson1</dc:creator>
      <dc:date>2025-10-15T00:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression Null Values and Total Score</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1658019#M11538</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
  name: 'TotalScore',
  expression: 'DefaultValue(Fingers1, 0) + DefaultValue(Fingers2, 0) + DefaultValue(Fingers3, 0) + DefaultValue(Barrel, 0) + DefaultValue(Serpentine, 0) + DefaultValue(AlleyDock, 0) + DefaultValue(StreetOffset, 0) + DefaultValue(Mailbox, 0) + DefaultValue(TirePush, 0) + DefaultValue(PlowDrop, 0)',
  statistic: 'SUM'
}&lt;/LI-CODE&gt;&lt;P&gt;This should set the value to 0 when the items are 'null'&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 14:21:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1658019#M11538</guid>
      <dc:creator>Neal_t_k</dc:creator>
      <dc:date>2025-10-15T14:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression Null Values and Total Score</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1658020#M11539</link>
      <description>&lt;P&gt;You can do something similar in the GroupBy as well.&lt;/P&gt;&lt;LI-CODE lang="python"&gt; {name: 'Fingers1score', expression: 'DefaultValue(Fingers1, 0)', statistic: 'SUM' }&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 15 Oct 2025 14:25:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1658020#M11539</guid>
      <dc:creator>Neal_t_k</dc:creator>
      <dc:date>2025-10-15T14:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression Null Values and Total Score</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1658205#M11547</link>
      <description>&lt;P&gt;Thank you for your responses! We got it to work using the code below. This was created using a combination of your responses and fed into Gemini and Copilot.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var fs = FeaturesetByPortalItem(
    Portal("https://cohgov.maps.arcgis.com"), // your Portal's url
    "b8411078d5fc40c9b65012fe72e02a4d",       // the service id
    0,                                        // the sub-layer id
    ['Truck_No', 'Fingers1', 'Fingers2', 'Fingers3', 'Barrel', 'Serpentine', 'AlleyDock', 'StreetOffset', 'Mailbox', 'TirePush', 'PlowDrop'], // the fields you want to load
    false                                     // do you want to load geometries
    )

var fs_clean_features = [];
// Define the fields for the new featureset structure
var fields_to_include = [
    { name: 'Truck_No', type: 'esriFieldTypeString' },
    { name: 'Fingers1', type: 'esriFieldTypeDouble' },
    { name: 'Fingers2', type: 'esriFieldTypeDouble' },
    { name: 'Fingers3', type: 'esriFieldTypeDouble' },
    { name: 'Barrel', type: 'esriFieldTypeDouble' },
    { name: 'Serpentine', type: 'esriFieldTypeDouble' },
    { name: 'AlleyDock', type: 'esriFieldTypeDouble' },
    { name: 'StreetOffset', type: 'esriFieldTypeDouble' },
    { name: 'Mailbox', type: 'esriFieldTypeDouble' },
    { name: 'TirePush', type: 'esriFieldTypeDouble' },
    { name: 'PlowDrop', type: 'esriFieldTypeDouble' }
];

for (var f in fs) {
    var newFeature = {
        attributes: {
            Truck_No: f['Truck_No'],
            // IIF(IsEmpty(f['FieldName']), 0, f['FieldName']) ensures the result is a number (0) or the original number.
            Fingers1: IIF(IsEmpty(f['Fingers1']), 0, f['Fingers1']),
            Fingers2: IIF(IsEmpty(f['Fingers2']), 0, f['Fingers2']),
            Fingers3: IIF(IsEmpty(f['Fingers3']), 0, f['Fingers3']),
            Barrel: IIF(IsEmpty(f['Barrel']), 0, f['Barrel']),
            Serpentine: IIF(IsEmpty(f['Serpentine']), 0, f['Serpentine']),
            AlleyDock: IIF(IsEmpty(f['AlleyDock']), 0, f['AlleyDock']),
            StreetOffset: IIF(IsEmpty(f['StreetOffset']), 0, f['StreetOffset']),
            Mailbox: IIF(IsEmpty(f['Mailbox']), 0, f['Mailbox']),
            TirePush: IIF(IsEmpty(f['TirePush']), 0, f['TirePush']),
            PlowDrop: IIF(IsEmpty(f['PlowDrop']), 0, f['PlowDrop'])
        }
    };
    Push(fs_clean_features, newFeature);
}

// -----------------------------------------------------
// CRITICAL FIX: Explicitly pass the schema and features
// -----------------------------------------------------
var fs_clean = Featureset({
    fields: fields_to_include,
    geometryType: '', // No geometry
    features: fs_clean_features
});


// Use fs_clean in the GroupBy function
return GroupBy(fs_clean, ['Truck_No'],
[
    // The individual score fields are calculated using the clean data (0 instead of null)
    {name: 'Fingers1score', expression: 'Fingers1', statistic: 'SUM' }, 
    {name: 'Fingers2score', expression: 'Fingers2', statistic: 'SUM' }, 
    {name: 'Fingers3score', expression: 'Fingers3', statistic: 'SUM' }, 
    {name: 'BarrelScore', expression: 'Barrel', statistic: 'SUM' }, 
    {name: 'SerpentineScore', expression: 'Serpentine', statistic: 'SUM' }, 
    {name: 'AlleyDockScore', expression: 'AlleyDock', statistic: 'SUM' }, 
    {name: 'StreetOffsetScore', expression: 'StreetOffset', statistic: 'SUM' }, 
    {name: 'MailboxScore', expression: 'Mailbox', statistic: 'SUM' }, 
    {name: 'TirePushScore', expression: 'TirePush', statistic: 'SUM' },
    {name: 'PlowDropScore', expression: 'PlowDrop', statistic: 'SUM' },
    
    // TotalScore will now correctly sum non-null values (0 for originals nulls)
    {
        name: 'TotalScore', 
        expression: 'Fingers1 + Fingers2 + Fingers3 + Barrel + Serpentine + AlleyDock + StreetOffset + Mailbox + TirePush + PlowDrop', 
        statistic: 'SUM' 
    }
]
)&lt;/LI-CODE&gt;&lt;P&gt;Screenshot of the finished Dashboard.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndrewWilson1_0-1760555471052.png" style="width: 785px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/142070i1ABB3B01ABC283DE/image-dimensions/785x579?v=v2" width="785" height="579" role="button" title="AndrewWilson1_0-1760555471052.png" alt="AndrewWilson1_0-1760555471052.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We have ideas for how we can improve for 2026!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 19:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-null-values-and-total-score/m-p/1658205#M11547</guid>
      <dc:creator>AndrewWilson1</dc:creator>
      <dc:date>2025-10-15T19:14:21Z</dc:date>
    </item>
  </channel>
</rss>

