<?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 To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608614#M11045</link>
    <description>&lt;P&gt;To get the latest inspection for all of the hydrants, this code should work. Make sure you change the name of 'HyrantID' to the correct field name&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var inspections = FeatureSetByPortalItem(
Portal("https://maps.casselberry.org/portal"),
"f3a4a8879ce34241a5fd139ddfaf727a", // Inspection Layer Item ID
0
);
GroupBy(inspections , 'HyrantID', {name: 'Latest', expression: 'dateinspected', statistic: 'MAX'})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Apr 2025 17:28:18 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2025-04-23T17:28:18Z</dc:date>
    <item>
      <title>Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608543#M11039</link>
      <description>&lt;P&gt;I have a hydrant inspection layer that I have configured a dashboard for and I am trying to get the indicator widget to reflect the correct number of hydrants still needing inspections. Currently the number is inflated because there are multiple inspections per hydrant. I have been working on trying to create a data expression to create a FeatureSet to filter most recent inspections per hydrant, but I am having no luck. Every code I have tried multiple code combinations, and it just returns an empty dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Load the hydrant inspections layer&lt;BR /&gt;var inspections = FeatureSetByPortalItem(&lt;BR /&gt;Portal("&lt;A href="https://maps.casselberry.org/portal" target="_blank"&gt;https://maps.casselberry.org/portal&lt;/A&gt;"),&lt;BR /&gt;"f3a4a8879ce34241a5fd139ddfaf727a", // Inspection Layer Item ID&lt;BR /&gt;0&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;var maxDate = Text(Date(Max(fs, 'dateinspected')), 'YYYY-MM-DD');&lt;BR /&gt;return Filter(fs, 'dateinspected = @maxDate');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code is based on this github post I had found&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MelanieBass_0-1745423030227.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/130813i8A7CCA05CB712970/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MelanieBass_0-1745423030227.png" alt="MelanieBass_0-1745423030227.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 15:47:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608543#M11039</guid>
      <dc:creator>MelanieBass</dc:creator>
      <dc:date>2025-04-23T15:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608562#M11040</link>
      <description>&lt;P&gt;The dataset in the Github repository example has that date in a text field, not a date field. If your field is a date field, you can do this much easier using the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#orderby" target="_self"&gt;OrderBy&lt;/A&gt; and &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#first" target="_self"&gt;First&lt;/A&gt; functions&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var inspections = FeatureSetByPortalItem(
Portal("https://maps.casselberry.org/portal"),
"f3a4a8879ce34241a5fd139ddfaf727a", // Inspection Layer Item ID
0
);
return First(OrderBy(inspections, "dateinspected DESC"));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 16:23:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608562#M11040</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-23T16:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608567#M11041</link>
      <description>&lt;P&gt;Thank you for your prompt response! I tested it and it appeared to work till I clicked done and then got this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MelanieBass_0-1745425568418.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/130818i2629BF7CD947A89D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MelanieBass_0-1745425568418.png" alt="MelanieBass_0-1745425568418.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 16:26:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608567#M11041</guid>
      <dc:creator>MelanieBass</dc:creator>
      <dc:date>2025-04-23T16:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608580#M11042</link>
      <description>&lt;P&gt;Ah, I forgot the first rule of Data Expressions...always return a FeatureSet.&lt;/P&gt;&lt;P&gt;This should work&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var inspections = FeatureSetByPortalItem(
Portal("https://maps.casselberry.org/portal"),
"f3a4a8879ce34241a5fd139ddfaf727a", // Inspection Layer Item ID
0
);
var feat = First(OrderBy(inspections, "dateinspected DESC"));
var dict = { fields: Schema(inspections ).fields, features: [feat] };
return FeatureSet(dict);&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 23 Apr 2025 16:39:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608580#M11042</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-23T16:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608583#M11043</link>
      <description>&lt;P&gt;Unfortunately still not working..&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MelanieBass_0-1745426632935.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/130823iFCFA6D07B45158A4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MelanieBass_0-1745426632935.png" alt="MelanieBass_0-1745426632935.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Will this code return most recent for EACH hydrant not just most recent inspections done for all hydrants? so most recent inspection per hydrantid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 16:45:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608583#M11043</guid>
      <dc:creator>MelanieBass</dc:creator>
      <dc:date>2025-04-23T16:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608596#M11044</link>
      <description>&lt;P&gt;Are you using an older version of Enterprise? If so, you'll have to use&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return FeatureSet(Text(dict));&lt;/LI-CODE&gt;&lt;P&gt;And yes, this code only returns the most recent inspection.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 17:10:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608596#M11044</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-23T17:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608614#M11045</link>
      <description>&lt;P&gt;To get the latest inspection for all of the hydrants, this code should work. Make sure you change the name of 'HyrantID' to the correct field name&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var inspections = FeatureSetByPortalItem(
Portal("https://maps.casselberry.org/portal"),
"f3a4a8879ce34241a5fd139ddfaf727a", // Inspection Layer Item ID
0
);
GroupBy(inspections , 'HyrantID', {name: 'Latest', expression: 'dateinspected', statistic: 'MAX'})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 17:28:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608614#M11045</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-23T17:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608640#M11046</link>
      <description>&lt;P&gt;OMG this worked! Thank you soooo much! I have been going crazy with this code for days! I appreciate it!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 18:24:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1608640#M11046</guid>
      <dc:creator>MelanieBass</dc:creator>
      <dc:date>2025-04-23T18:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1610561#M11063</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;Your code that you gave worked beautifully however, I have now some hydrant inspections that have defaulted the null value for date 12/30/1899 and I also need those to return in the feature set. Is this possible with editing your original code?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2025 18:36:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1610561#M11063</guid>
      <dc:creator>MelanieBass</dc:creator>
      <dc:date>2025-04-30T18:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1610576#M11064</link>
      <description>&lt;P&gt;You can add multiple statistics to the GroupBy function. This will return the latest and earliest inspections for each hydrant. However, this does not include dates that are null&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;GroupBy(inspections , 'HydrantID', [{name: 'Latest', expression: 'dateinspected', statistic: 'MAX'},{name: 'Earliest', expression: 'dateinspected', statistic: 'MIN'}])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2025 19:19:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1610576#M11064</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-30T19:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression To Return Most Recent Date for Hydrant Inspection in Dashboard Indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1610595#M11065</link>
      <description>&lt;P&gt;This worked! thanks again. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2025 20:37:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-return-most-recent-date-for/m-p/1610595#M11065</guid>
      <dc:creator>MelanieBass</dc:creator>
      <dc:date>2025-04-30T20:37:00Z</dc:date>
    </item>
  </channel>
</rss>

