<?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: Date fields in data expressions for serial charts in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1299934#M7958</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:26:32 GMT</pubDate>
    <dc:creator>DavidNyenhuis1</dc:creator>
    <dc:date>2023-06-15T19:26:32Z</dc:date>
    <item>
      <title>Date fields in data expressions for serial charts</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1135728#M5761</link>
      <description>&lt;P&gt;Seeking some assistance with what i think is just a formatting problem.&lt;/P&gt;&lt;P&gt;I've used this script in a data expression to power a serial chart showing the time of day in 24hr format for a dataset collected in ArcGIS Collector. The original reason for doing this as a data expression was to gain access to a field that just had the time of day (or rounded up to an hour value from 1 - 24)&lt;/P&gt;&lt;P&gt;Everything works well at this stage&lt;/P&gt;&lt;P&gt;What I'm trying to do now is include the original creation_date field in the featureset so that I can filter this field with a date category selector. As it is now, the creation date field is being treated as a string and when I attempt to apply a filter a this data expression via the date category selector, there are no valid fields to choose from.&lt;/P&gt;&lt;P&gt;If I change line 18 of the code from&amp;nbsp;esriFieldTypeString to&amp;nbsp;esriFieldTypeDate, the&amp;nbsp;featureset doesn't return any records.&lt;/P&gt;&lt;P&gt;The creation_date field is actually of type&amp;nbsp;esriFieldTypeDate, so the problem must be with my scripting. Any suggestions are most welcome&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 906px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31941i9897CB7A6FF10067/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//ground activity - time of day
//obtains the hour in military (long) format from the creation_date field

// Write an expression that returns a FeatureSet.
// Documentation: https://arcg.is/3c419TD
// Samples: https://arcg.is/38SEWWz



// Create a FeatureSet from the Feature Layer containing the Ground activitydata.
var fs =FeatureSetByPortalItem(Portal('https://gis.xxxxxx.xx.xx.xx/portal'), '0116ef7ee89c4de0829fe554315e2177', 0)



var dowDict = { 
  'fields': [{ 'name': 'dow_num', 'type': 'esriFieldTypeInteger'},
  {'name': 'OBJECTID','type': 'esriFieldTypeInteger'},
  {'name': 'creation_date','type': 'esriFieldTypeString'},
  {'name': 'militaryhr', 'type': 'esriFieldTypeString'},
  {'name': 'Shooter_Organisation','type': 'esriFieldTypeString'},
  {'name': 'species', 'type': 'esriFieldTypeString'}], 
  'geometryType': '', 
  'features': [] 
}; 

var index = 0; 

for (var feature in fs) { 
    dowDict.features[index] = { 
        'attributes': { 
            'dow_num': Hour(feature['creation_date']), 
            'objectid': feature['OBJECTID'],
            'creation_date': feature['creation_date'],
            'militaryhr': Text(feature['creation_date'], 'HH'),
            'Shooter_Organisation': feature['Shooter_Organisation'],
            'species': feature['species_common_name'] 
        }} 
    index++;} 

// Convert dictionary to feature set. 
//var fs_dict = FeatureSet(Text(dowDict)); 
var fs_dict = FeatureSet(Text(dowDict)); 

// Return case data by day of Hour
return fs_dict;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 03:26:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1135728#M5761</guid>
      <dc:creator>ChrisH2</dc:creator>
      <dc:date>2022-01-21T03:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date fields in data expressions for serial charts</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1135734#M5762</link>
      <description>&lt;P&gt;I've seen this sort of behavior in Data Expressions with date fields.&lt;/P&gt;&lt;P&gt;I don't understand &lt;EM&gt;why &lt;/EM&gt;this works, but try casting it as a &lt;STRONG&gt;Number&lt;/STRONG&gt;. In line 33, you'd put:&lt;/P&gt;&lt;PRE&gt;'creation_date': Number(feature['creation_date']),&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Trying to use a date value directly." style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31942i2EC2FCB5ACDF3D7D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1642736662732.png" alt="Trying to use a date value directly." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Trying to use a date value directly.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cast as number." style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31943i7435C06185681E1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1642736720696.png" alt="Cast as number." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Cast as number.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 03:46:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1135734#M5762</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-01-21T03:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date fields in data expressions for serial charts</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1135736#M5763</link>
      <description>&lt;P&gt;Worked perfectly. Thankyou so much&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 03:55:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1135736#M5763</guid>
      <dc:creator>ChrisH2</dc:creator>
      <dc:date>2022-01-21T03:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Date fields in data expressions for serial charts</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1233086#M7003</link>
      <description>&lt;P&gt;I was stuck with the exact situation too.&amp;nbsp; &amp;nbsp;Thank you, that worked perfectly for me also.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 02:39:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1233086#M7003</guid>
      <dc:creator>TimWarfe_MSC</dc:creator>
      <dc:date>2022-11-18T02:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date fields in data expressions for serial charts</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1299934#M7958</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:26:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/date-fields-in-data-expressions-for-serial-charts/m-p/1299934#M7958</guid>
      <dc:creator>DavidNyenhuis1</dc:creator>
      <dc:date>2023-06-15T19:26:32Z</dc:date>
    </item>
  </channel>
</rss>

