<?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: Pass values to new columns Arcade in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1299939#M7960</link>
    <description>&lt;P&gt;With this week's update to Arcade and ArcGIS Dashboards, date fields in feature set constructors now just work. You no longer have to wrap dates with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Number()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if you pass the &lt;EM&gt;dictionary&lt;/EM&gt; into the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;FeatureSet()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function (which as of this release accepts a dictionary as opposed to only text based JSON).&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;PRE&gt;return FeatureSet(Text(dict))&lt;/PRE&gt;&lt;P&gt;Do this:&lt;/P&gt;&lt;PRE&gt;return FeatureSet(dict)&lt;/PRE&gt;&lt;P&gt;Learn more in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/arcgis-dashboards-blog/dashboard-data-expressions-what-has-changed-june/ba-p/1298782" target="_blank" rel="noopener"&gt;this blog post&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;NOTE: For Enterprise users, this update is targeted for 11.2&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2023 19:28:41 GMT</pubDate>
    <dc:creator>DavidNyenhuis1</dc:creator>
    <dc:date>2023-06-15T19:28:41Z</dc:date>
    <item>
      <title>Pass values to new columns Arcade</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1110754#M5304</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to pass field values to different columns, and also remove the time in the date (like in the image below). I wrote a piece of code but it doesn't work.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VeronicaArambula_0-1635156307937.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/26045i5A0FBF8D1CAB9D5F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VeronicaArambula_0-1635156307937.png" alt="VeronicaArambula_0-1635156307937.png" /&gt;&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="java"&gt;// Reference layer using the FeatureSetByPortalItem() method. 
var fs = FeatureSetByPortalItem(Portal('https://arcgis.com/'), '74d6c3d630c14458a3c23c71a19447ad', 0, ['*'], false);

// Empty dictionary to capture each value 
var choicesDict = {'fields': [{ 'name': 'ID', 'type': 'esriFieldTypeString'}, 
                              { 'name': 'dates', 'type': 'esriFieldTypeDate'},
                              { 'name': 'morning', 'type': 'esriFieldTypeString'},
                              { 'name': 'afternoon', 'type': 'esriFieldTypeString'},
                              { 'name': 'night', 'type': 'esriFieldTypeString'}], 
                    'geometryType': '', 
                    'features': []}; 

// Store values in the dictionary
for (var feature in fs) {
    var id = feature['ID']
    var actdate = feature['actionDate']
    var morning = feature['Shift_vehicles'] == 'Morning check (6-7am)'
    var afternoon = feature['Shift_vehicles'] == 'Afternoon check (2-4pm)'
    var night = feature['Shift_vehicles'] == 'Night check (11pm-1am)'
    Push(choicesDict.features, {"attributes": {"ID": id, 
                                               "dates": actdate,
                                               "morning": morning,
                                               "afternoon": afternoon,
                                               "night": night}})
} 

//return choicesDict

// Convert dictionary to featureSet. 
var fs_dict = FeatureSet(Text(choicesDict)); 
return fs_dict
// Return featureset  
return GroupBy(fs_dict, ['ID', 'dates'],
       [{ name: 'morning', expression: 'morning', statistic: 'COUNT' },
        { name: 'afternoon', expression: 'afternoon', statistic: 'COUNT' },
        { name: 'night', expression: 'night', statistic: 'COUNT' }]); &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;&lt;P&gt;&amp;nbsp;&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 07:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1110754#M5304</guid>
      <dc:creator>VeronicaArambula</dc:creator>
      <dc:date>2021-10-27T07:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Pass values to new columns Arcade</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1111965#M5316</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/523972"&gt;@VeronicaArambula&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe it is due to the date formatting - expecting in &lt;SPAN&gt;UNIX timestamp.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also helped to modify the date (remove time) and logic for counting if false (changed to null)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Reference layer using the FeatureSetByPortalItem() method. 
var fs = FeatureSetByPortalItem(Portal('https://arcgis.com/'), '74d6c3d630c14458a3c23c71a19447ad', 0, ['*'], false);

// Empty dictionary to capture each value 
var choicesDict = {'fields': [{ 'name': 'ID', 'type': 'esriFieldTypeString'}, 
                              { 'name': 'dates', 'type': 'esriFieldTypeDate'},
                              { 'name': 'morning', 'type': 'esriFieldTypeString'},
                              { 'name': 'afternoon', 'type': 'esriFieldTypeString'},
                              { 'name': 'night', 'type': 'esriFieldTypeString'}], 
                    'geometryType': '', 
                    'features': []}; 
//define the start of date
var start = ToLocal(Date(1970, 0, 01, 0, 0, 0, 0))
// Store values in the dictionary
for (var feature in fs) {
    var id = feature['ID']
    //remove the time
    var actdate = Date(Year(feature['actionDate']),Month(feature['actionDate']),Day(feature['actionDate']))
    //Calculate the difference
    var dt = DateDiff(actdate, start, 'milliseconds')
    //make the value to null for count
    var morning = Iif(feature['Shift_vehicles'] == 'Morning check (6-7am)',1,null)
    var afternoon = Iif(feature['Shift_vehicles'] == 'Afternoon check (2-4pm)',1,null)
    var night = Iif(feature['Shift_vehicles'] == 'Night check (11pm-1am)',1,null)
    Push(choicesDict.features, {"attributes": {"ID": id, 
                                               "dates": dt,
                                               "morning": morning,
                                               "afternoon": afternoon,
                                               "night": night}})
} 

//return choicesDict

// Convert dictionary to featureSet. 
var fs_dict = FeatureSet(Text(choicesDict)); 
return fs_dict
// Return featureset  
return GroupBy(fs_dict, ['ID', 'dates'],
       [{ name: 'morning', expression: 'morning', statistic: 'COUNT' },
        { name: 'afternoon', expression: 'afternoon', statistic: 'COUNT' },
        { name: 'night', expression: 'night', statistic: 'COUNT' }]); &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Cheers,&lt;/P&gt;&lt;P&gt;Tang&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 01:28:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1111965#M5316</guid>
      <dc:creator>SzuNyiapTang</dc:creator>
      <dc:date>2021-10-28T01:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Pass values to new columns Arcade</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1112006#M5317</link>
      <description>&lt;P&gt;Oh wow!!! Thank you very very much!! It works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'd like to ask you one thing:&lt;/P&gt;&lt;P&gt;1. why is it necessary to add the start date and then use the DateDiff?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 07:43:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1112006#M5317</guid>
      <dc:creator>VeronicaArambula</dc:creator>
      <dc:date>2021-10-28T07:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Pass values to new columns Arcade</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1112273#M5324</link>
      <description>&lt;P&gt;Hi Veronica,&lt;/P&gt;&lt;P&gt;For the date field, it is expecting in the format of Unix Timestamp which is the elapsed time after&amp;nbsp;&lt;SPAN&gt;January 1st, 1970 at UTC.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Tang&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 22:13:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1112273#M5324</guid>
      <dc:creator>SzuNyiapTang</dc:creator>
      <dc:date>2021-10-28T22:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Pass values to new columns Arcade</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1299939#M7960</link>
      <description>&lt;P&gt;With this week's update to Arcade and ArcGIS Dashboards, date fields in feature set constructors now just work. You no longer have to wrap dates with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Number()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if you pass the &lt;EM&gt;dictionary&lt;/EM&gt; into the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;FeatureSet()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function (which as of this release accepts a dictionary as opposed to only text based JSON).&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;PRE&gt;return FeatureSet(Text(dict))&lt;/PRE&gt;&lt;P&gt;Do this:&lt;/P&gt;&lt;PRE&gt;return FeatureSet(dict)&lt;/PRE&gt;&lt;P&gt;Learn more in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/arcgis-dashboards-blog/dashboard-data-expressions-what-has-changed-june/ba-p/1298782" target="_blank" rel="noopener"&gt;this blog post&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;NOTE: For Enterprise users, this update is targeted for 11.2&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 19:28:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-values-to-new-columns-arcade/m-p/1299939#M7960</guid>
      <dc:creator>DavidNyenhuis1</dc:creator>
      <dc:date>2023-06-15T19:28:41Z</dc:date>
    </item>
  </channel>
</rss>

