<?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: Dashboard Data Expressions for Recalculating Returns Error in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292240#M7861</link>
    <description>&lt;UL&gt;&lt;LI&gt;You're trying to access the field "county" from the Featureset (fs). This isn't possible, you have to do it with the Feature (f)&lt;/LI&gt;&lt;LI&gt;Your condition is wrong. The OR operator ( || ) combines multiple "standalone" expressions, each one has to be able to be evaluated. You want something like this:&lt;UL&gt;&lt;LI&gt;f["county"] == "Carbon" || f["county"] == "Beaver || f["county"] == "Box Elder"&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;This isn't very fun to write, but that's what the &lt;A href="https://developers.arcgis.com/arcade/function-reference/array_functions/#includes" target="_blank" rel="noopener"&gt;Includes()&lt;/A&gt; function is for:&lt;UL&gt;&lt;LI&gt;IIf(Includes(["County 1", "County 2", "County 3"], f["county"], ...)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Instead of nesting these IIf(), use &lt;A href="https://developers.arcgis.com/arcade/function-reference/logical_functions/#when" target="_blank" rel="noopener"&gt;When()&lt;/A&gt;.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for(var f in fs) {
    var c = f["county"]
    var member = When(
        Includes(["C1", "C2", "C3"], c), "Member1",
        Includes(["C4", "C5", "C6"], c), "Member2",
        Includes(["C7", "C8"], c), "Member3",
        "Not assigned to any member"
    )
    Push(recalc.features, {attributes: {memberName: member}})
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2023 18:53:03 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-05-23T18:53:03Z</dc:date>
    <item>
      <title>Dashboard Data Expressions for Recalculating Returns Error</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292217#M7860</link>
      <description>&lt;P&gt;Some context: I have a dashboard where I want reviewers to go in and see/edit applications. The dashboard is set up and functioning, but I'd like to set up a filter/Category Selector for the dashboard based on the reviewer (each reviewer would be looking at all the applications for specific counties, i.e. Reviewer A looks at counties X, Y and Z while Reviewer B looks at counties L, M, N and O). My idea is to have a grouped value category selector based on a Data Expression that calculates who the reviewer would be for that application based on the county.&lt;/P&gt;&lt;P&gt;This is what I'm trying:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var p = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(p,'9cfe5d169a4e4b34a79c8640b7a924ee',0,['county'], false);

var recalc = {
  'fields': [{'name':'memberName', 'type':'esriFieldTypeString'}],
  'geometryType': '',
  'features': []
}
for(var f in fs) {
  var new_f = {'attributes': {'memberName':
 iif(fs["county"]=='Carbon'||'Beaver'||'Box Elder'||'Juab',"Jim XXXXX",
iif(fs["county"]=='Grand'||'Davis'||'Kane'||'San Juan'||'Uintah',"Kris XXXXX",
iif(fs["county"]=='Utah'||'Duchesne'||'Millard'||'Sanpete'||'Washington',"Anna XXXXX",
iif(fs["county"]=='Wasatch'||'Emery'||'Morgan'||'Sevier'||'Wayne',"Tracy XXXXX",
iif(fs["county"]=='Salt Lake'||'Garfield'||'Piute'||'Summit'||'Weber',"Chad XXXXX",
iif(fs["county"]=='Cache'||'Iron'||'Rich'||'Tooele'||'Daggett',"Alan XXXXX","Manual Review"))))))}}
  Push(recalc.features, new_f)
}
return FeatureSet(Text(recalc))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I always get the error:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Test execution error: Execution error - Cannot access value using a key of this type. Verify test data.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;What I'm referencing is a hosted feature layer view (though no more success with the hosted feature layer), and neither are empty. There are related tables, but I am not referencing here (layers [1] and [2] are related, but [0] is the point feature layer).&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 May 2023 18:30:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292217#M7860</guid>
      <dc:creator>GIS_utahDEM</dc:creator>
      <dc:date>2023-05-23T18:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard Data Expressions for Recalculating Returns Error</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292240#M7861</link>
      <description>&lt;UL&gt;&lt;LI&gt;You're trying to access the field "county" from the Featureset (fs). This isn't possible, you have to do it with the Feature (f)&lt;/LI&gt;&lt;LI&gt;Your condition is wrong. The OR operator ( || ) combines multiple "standalone" expressions, each one has to be able to be evaluated. You want something like this:&lt;UL&gt;&lt;LI&gt;f["county"] == "Carbon" || f["county"] == "Beaver || f["county"] == "Box Elder"&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;This isn't very fun to write, but that's what the &lt;A href="https://developers.arcgis.com/arcade/function-reference/array_functions/#includes" target="_blank" rel="noopener"&gt;Includes()&lt;/A&gt; function is for:&lt;UL&gt;&lt;LI&gt;IIf(Includes(["County 1", "County 2", "County 3"], f["county"], ...)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Instead of nesting these IIf(), use &lt;A href="https://developers.arcgis.com/arcade/function-reference/logical_functions/#when" target="_blank" rel="noopener"&gt;When()&lt;/A&gt;.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for(var f in fs) {
    var c = f["county"]
    var member = When(
        Includes(["C1", "C2", "C3"], c), "Member1",
        Includes(["C4", "C5", "C6"], c), "Member2",
        Includes(["C7", "C8"], c), "Member3",
        "Not assigned to any member"
    )
    Push(recalc.features, {attributes: {memberName: member}})
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 18:53:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292240#M7861</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-05-23T18:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard Data Expressions for Recalculating Returns Error</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292257#M7862</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;Thank you, that worked!&lt;/P&gt;&lt;P&gt;Any chance you also know how to add the objectID or globalid to the new recalc table? I added in lines 2, 6 and 12 but I get "&lt;SPAN&gt;Test execution error: Invalid variable assignment.. Verify test data."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var p = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(p,'9cfe5d169a4e4b34a79c8640b7a924ee',0,['county','objectid'], false);

var recalc = {
  'fields': [{'name':'memberName', 'type':'esriFieldTypeString'},
  {'name':'id','type':'esriFieldTypeString'}],
  'geometryType': '',
  'features': []
}
for(var f in fs) {
  var new_f = {'attributes': {'memberName': CALCULATED}
  'id':f['objectid']}
  Push(recalc.features, new_f)
}
return FeatureSet(Text(recalc))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 19:11:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292257#M7862</guid>
      <dc:creator>GIS_utahDEM</dc:creator>
      <dc:date>2023-05-23T19:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard Data Expressions for Recalculating Returns Error</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292259#M7863</link>
      <description>&lt;P&gt;Your braces in lines 11 &amp;amp; 12 are wrong, you have your id field outside of the attributes.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Push(recalc.features, {attributes: {memberName: member, id: f.OBJECTID}})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 19:14:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-data-expressions-for-recalculating/m-p/1292259#M7863</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-05-23T19:14:49Z</dc:date>
    </item>
  </channel>
</rss>

