<?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 Return Newest Record For an Asset ID in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/return-newest-record-for-an-asset-id/m-p/1646303#M7587</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am trying to filter records in a way that shows only the newest record for any given asset ID. For example, Asset 100 has 3 entries in the layer, with dates of 1/1/1999, 2/1/2000 and 1/5/2019 on each record. I want to have an arcade statement return only the record with the newest date IE 1/5/2019.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I am close, but I am getting an error in the Arcade console saying 'GroupBy' is undefined. I can't figure out what the issue is.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code I have so far:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var latestByAsset = GroupBy($feature, "AssetID", {
  name: "LatestDate",
  expression: "InspectionDate",
  statistic: "MAX"
});

var newestRecords = [];

// Loop through the grouped results
for (var g in latestByAsset) {
  // Filter the layer to find the record that matches both AssetID and LatestDate
  var matchSet = Filter($feature, "AssetID = @g.AssetID AND DateField = @g.LatestDate");
  var match = First(matchSet);

  // If a match is found, add it to the result
  if (!IsEmpty(match)) {
    Push(newestRecords, match);
  }
}

return newestRecords;&lt;/LI-CODE&gt;&lt;P&gt;What am I missing?&lt;/P&gt;</description>
    <pubDate>Wed, 27 Aug 2025 23:12:30 GMT</pubDate>
    <dc:creator>AKRRMapGuy</dc:creator>
    <dc:date>2025-08-27T23:12:30Z</dc:date>
    <item>
      <title>Return Newest Record For an Asset ID</title>
      <link>https://community.esri.com/t5/developers-questions/return-newest-record-for-an-asset-id/m-p/1646303#M7587</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am trying to filter records in a way that shows only the newest record for any given asset ID. For example, Asset 100 has 3 entries in the layer, with dates of 1/1/1999, 2/1/2000 and 1/5/2019 on each record. I want to have an arcade statement return only the record with the newest date IE 1/5/2019.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I am close, but I am getting an error in the Arcade console saying 'GroupBy' is undefined. I can't figure out what the issue is.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code I have so far:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var latestByAsset = GroupBy($feature, "AssetID", {
  name: "LatestDate",
  expression: "InspectionDate",
  statistic: "MAX"
});

var newestRecords = [];

// Loop through the grouped results
for (var g in latestByAsset) {
  // Filter the layer to find the record that matches both AssetID and LatestDate
  var matchSet = Filter($feature, "AssetID = @g.AssetID AND DateField = @g.LatestDate");
  var match = First(matchSet);

  // If a match is found, add it to the result
  if (!IsEmpty(match)) {
    Push(newestRecords, match);
  }
}

return newestRecords;&lt;/LI-CODE&gt;&lt;P&gt;What am I missing?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2025 23:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-newest-record-for-an-asset-id/m-p/1646303#M7587</guid>
      <dc:creator>AKRRMapGuy</dc:creator>
      <dc:date>2025-08-27T23:12:30Z</dc:date>
    </item>
  </channel>
</rss>

