<?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: Arcade Data Expressions with Date Column Not Working in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1261414#M7391</link>
    <description>&lt;P&gt;Thank you for the responses.&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;'s response was the ticket.&amp;nbsp; Wrapping the reference to the input &lt;EM&gt;FeatureSet's date column translated the date into a unix timestamp integer, which then outputed correctly on the return statement.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Something else I noted was that null dates in the source data will get converted to a zero when the number function is called. On the output FeatureSet these zero's will appear as Jan 1, 1970.&amp;nbsp; So to fix that I also had to wrap the number function in an IIF function, and then return null if the incoming number() value is zero.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;So the column request looks like this:&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#808080"&gt;&lt;STRONG&gt;&lt;EM&gt;//If incoming date value is zero then return null, else return the date value as a unix timstamp integer&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;EM&gt;MY_OUT_DATE_COLUMN: iif (number(f["MY_IN_DATE_COLUMN"]) == 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,null&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,number(f["MY_IN_DATE_COLUMN"])&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 24 Feb 2023 14:51:48 GMT</pubDate>
    <dc:creator>AndrewRudin1</dc:creator>
    <dc:date>2023-02-24T14:51:48Z</dc:date>
    <item>
      <title>Arcade Data Expressions with Date Column Not Working</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1260473#M7365</link>
      <description>&lt;P&gt;I'm curious if anyone has had issues creating a data expression for Arcade in Dashboards that returns a date column?&lt;/P&gt;&lt;P&gt;I've noticed that if I include a date column in the FeatureSet I'm returning at the end of the script, the output contains no rows.&amp;nbsp; Based on my testing I believe this is a bug in the FeatureSet() function if the dictionary you pass to it contains a date column.&amp;nbsp; But since Arcade is pretty new to me maybe I'm doing something wrong&lt;/P&gt;&lt;P&gt;As an example, I put two samples below of the same code based on a public facing AGOL hosted feature layer.&amp;nbsp; The first sample has the date column removed so you can see it does return data.&amp;nbsp; The second sample the only difference is the date column is included, but you'll notice if you run it the results are blank.&amp;nbsp; I tried this with two AGOL feature layers, so it doesn't seem to be a fluke with just one layer.&lt;/P&gt;&lt;P&gt;I'm trying to follow along on the GitHub example on how to join tabular data to one of my layers and returns a feature set (&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/JoinLayerFieldsToTable.md" target="_self"&gt;Link&lt;/A&gt;).&amp;nbsp; Ultimately I want to slice and dice the layer in Arcade, but for this forum question I kept the script simple to show the issue.&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Here's sample script 1 with the date column commented out.&amp;nbsp; If you run in the Arcade playground you will se it returns data.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var portal = Portal("https://www.arcgis.com/");

var features = [];
var feat;

//Define input layer to read
var fs = FeatureSetByPortalItem(
    portal,
    "a400f4711f9443a9855340ee7b66890a",
    0,
    ['DRAINAGE_ID','LOCATION','FME_DATE'],
    false
    );

//Loop over each  hosted layer feature
//, pass subset of attribute values to the feat variable
//, then Push the feat object into the feature dictionary
for (var f in fs) {
    feat = {
        attributes: {
            DRAINAGE_ID: f["DRAINAGE_ID"],
            LOCATION: f["LOCATION"],
            //FME_DATE: f["FME_DATE"],
        }
    }
    Push(features,feat)
}    

//Define schema for output dictionary
//and pass in the dictionary of output features
var joinedDict = {
    fields: [
        {name: "DRAINAGE_ID", type: "esriFieldTypeInteger"},
        {name: "LOCATION", type: "esriFieldTypeString"},
        //{name: "FME_DATE", type: "esriFieldTypeDate"}
        ],
        'geometryType': '',
        'features':features
};

return FeatureSet(Text(joinedDict));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Here is sample 2 that includes the date column, but when you run it the results will be blank&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var portal = Portal("https://www.arcgis.com/");

var features = [];
var feat;

//Define input layer to read
var fs = FeatureSetByPortalItem(
    portal,
    "a400f4711f9443a9855340ee7b66890a",
    0,
    ['DRAINAGE_ID','LOCATION','FME_DATE'],
    false
    );

//Loop over each  hosted layer feature
//, pass subset of attribute values to the feat variable
//, then Push the feat object into the feature dictionary
for (var f in fs) {
    feat = {
        attributes: {
            DRAINAGE_ID: f["DRAINAGE_ID"],
            LOCATION: f["LOCATION"],
            FME_DATE: f["FME_DATE"],
        }
    }
    Push(features,feat)
}    

//Define schema for output dictionary
//and pass in the dictionary of output features
var joinedDict = {
    fields: [
        {name: "DRAINAGE_ID", type: "esriFieldTypeInteger"},
        {name: "LOCATION", type: "esriFieldTypeString"},
        {name: "FME_DATE", type: "esriFieldTypeDate"}
        ],
        'geometryType': '',
        'features':features
};

return FeatureSet(Text(joinedDict));
//If you instead return just the Text(joinedDict) you will see that the data looks valid
//, so it's just way the FeatureSet() function is transforming the data that seems to cause blank results
//return Text(joinedDict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 14:59:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1260473#M7365</guid>
      <dc:creator>AndrewRudin1</dc:creator>
      <dc:date>2023-02-22T14:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expressions with Date Column Not Working</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1260539#M7367</link>
      <description>&lt;P&gt;In Data Expressions, date fields need to be wrapped in the &lt;STRONG&gt;Number&lt;/STRONG&gt; function in order to work properly. Try this:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;...
    FME_DATE: Number(f["FME_DATE"]),
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 17:02:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1260539#M7367</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-02-22T17:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expressions with Date Column Not Working</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1260830#M7378</link>
      <description>&lt;P&gt;Related Idea trying to get this fixed:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-online-ideas/arcade-allow-date-values-in-date-fields/idi-p/1204894" target="_blank"&gt;Arcade: Allow Date() values in date fields (esriFi... - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 12:17:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1260830#M7378</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-23T12:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expressions with Date Column Not Working</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1261414#M7391</link>
      <description>&lt;P&gt;Thank you for the responses.&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;'s response was the ticket.&amp;nbsp; Wrapping the reference to the input &lt;EM&gt;FeatureSet's date column translated the date into a unix timestamp integer, which then outputed correctly on the return statement.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Something else I noted was that null dates in the source data will get converted to a zero when the number function is called. On the output FeatureSet these zero's will appear as Jan 1, 1970.&amp;nbsp; So to fix that I also had to wrap the number function in an IIF function, and then return null if the incoming number() value is zero.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;So the column request looks like this:&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#808080"&gt;&lt;STRONG&gt;&lt;EM&gt;//If incoming date value is zero then return null, else return the date value as a unix timstamp integer&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;EM&gt;MY_OUT_DATE_COLUMN: iif (number(f["MY_IN_DATE_COLUMN"]) == 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,null&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,number(f["MY_IN_DATE_COLUMN"])&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 24 Feb 2023 14:51:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1261414#M7391</guid>
      <dc:creator>AndrewRudin1</dc:creator>
      <dc:date>2023-02-24T14:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expressions with Date Column Not Working</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1261416#M7392</link>
      <description>&lt;P&gt;Thanks Johannes.&amp;nbsp; I upvoted that idea. Agreed that this could be improved to be more seamless.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 14:53:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1261416#M7392</guid>
      <dc:creator>AndrewRudin1</dc:creator>
      <dc:date>2023-02-24T14:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expressions with Date Column Not Working</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1299933#M7957</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:25:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expressions-with-date-column-not/m-p/1299933#M7957</guid>
      <dc:creator>DavidNyenhuis1</dc:creator>
      <dc:date>2023-06-15T19:25:29Z</dc:date>
    </item>
  </channel>
</rss>

