Hello!
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.
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.
Here's the code I have so far:
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;
What am I missing?