Any one else experiencing issues with both distinct and filter functions since the last upgrade. Both the samples below were working perfectly then there is an upgrade and they stop. I cannot find any documentation saying they were due to change or be discontinued its baffling.
Distinct sample
function housecountinfo() {
var resdets = FeatureSetById($map, "111111111-layer-82", ["REF", "type1", "Status", "Units", "Studio", "onebed", "twobed", "threebed", "fourbed", "fivebedplus"], True);
var resact = Intersects($feature, resdets);
var stats = GroupBy(resact, [{ name: "Ref", expression: "Ref" }, { name: "type", expression: "type1" }, { name: "Status", expression: "Status" }],
[{ name: "Units", expression: "Units", statistic: "SUM" }, { name: "studio", expression: "studio", statistic: "SUM" }, { name: "onebed", expression: "onebed", statistic: "Sum" },
{ name: "twobed", expression: "twobed", statistic: "Sum" }, { name: "threebed", expression: "threebed", statistic: "Sum" }, { name: "fourbed", expression: "fourbed", statistic: "Sum" },
{ name: "fivebedplus", expression: "fivebedplus", statistic: "Sum" }]);
if (Count(stats) > 0) {
var uniqueRefs = Distinct(stats, "Ref");
var result = [];
for (var ref in uniqueRefs) {
var x = ref.Ref;
var filteredStats = Filter(stats, "Ref = @x");
var hncud = createUnitDict(filteredStats, 1, 1);
var ancud = createUnitDict(filteredStats, 2, 1);
var dncud = createUnitDict(filteredStats, 3, 1);
var hucud = createUnitDict(filteredStats, 1, 2);
var aucud = createUnitDict(filteredStats, 2, 2);
var ducud = createUnitDict(filteredStats, 3, 2);
var hcud = createUnitDict(filteredStats, 1, 3);
var acud = createUnitDict(filteredStats, 2, 3);
var dcud = createUnitDict(filteredStats, 3, 3);
var hcdata = {
ref: x,
Notcommenced: { summary: hncud.units + ancud.units + dncud.units },
Underconstruction: { summary: hucud.units + aucud.units + ducud.units },
Completed: { summary: hcud.units + dcud.units + acud.units },
unitbreakdown: {
astudio: [hncud.studio, ancud.studio, dncud.studio, hucud.studio, aucud.studio, ducud.studio, hcud.studio, acud.studio, dcud.studio],
bonebed: [hncud.onebed, ancud.onebed, dncud.onebed, hucud.onebed, aucud.onebed, ducud.onebed, hcud.onebed, acud.onebed, dcud.onebed],
ctwobed: [hncud.twobed, ancud.twobed, dncud.twobed, hucud.twobed, aucud.twobed, ducud.twobed, hcud.twobed, acud.twobed, dcud.twobed],
dthreebed: [hncud.threebed, ancud.threebed, dncud.threebed, hucud.threebed, aucud.threebed, ducud.threebed, hcud.threebed, acud.threebed, dcud.threebed],
efourbed: [hncud.fourbed, ancud.fourbed, dncud.fourbed, hucud.fourbed, aucud.fourbed, ducud.fourbed, hcud.fourbed, acud.fourbed, dcud.fourbed],
ffivebedplus: [hncud.fivebedplus, ancud.fivebedplus, dncud.fivebedplus, hucud.fivebedplus, aucud.fivebedplus, ducud.fivebedplus, hcud.fivebedplus, acud.fivebedplus, dcud.fivebedplus]
}
};
Push(result, hcdata);
}
return result;
} else {
return 9999;
}
}
and filter sample
function createUnitDict(filteredStats, type, status) {
var filtered = First(Filter(filteredStats, "type = @type AND Status = @status"));
if (IsEmpty(filtered)) {
return { units: 0, studio: 0, onebed: 0, twobed: 0, threebed: 0, fourbed: 0, fivebedplus: 0 };
} else {
return { units: filtered.Units, studio: filtered.studio, onebed: filtered.onebed, twobed: filtered.twobed, threebed: filtered.threebed, fourbed: filtered.fourbed, fivebedplus: filtered.fivebedplus };
}
}
Hey @LarryMcEvoy70
When you say they stopped working, what errors does this produce when you run? Also, What kind of upgrade was performed, from what version to what version?
Cody
Hi Cody,
Its all up on AGOL so whatever they did last week, didn't have time to investigate it until now because I was fixing other stuff that broke, The error for what its worth is Test execution error: Encountered unreachable logic. Verify test data. Debugging arcade is slow and tedious but found I was getting no return for the distinct so rewrote that section and then I discovered the filter was not fiving a return either so will have to rewrite that section as well. I always thought that the idea behind documented built in functions was that they worked consistently and you got warned about depreciation.
Ta
Larry
After a fairly substantial rewrite to add in a distinct and filter outside of the functions it is back working again. Does this actually need to happen from my viewpoint ESRI pushed a release out early in order to wave their shiny new toys at a user conference. We all like new features that help to make work easier but please stop breaking stuff that was working and maybe try a little testing before you do push a release.
I am also experiencing errors in my code since the June 2025 update, which also uses Distinct and Filters. I've submitted a case to Esri, but what does your new code look like?
if (Count(statsArray) > 0) {
var uniqueRefs = [];
var seenRefs = [];
for (var i = 0; i < Count(statsArray); i++) {
var s = statsArray[i];
Console("Processing stat:", s);
if (HasKey(s, "ref")) {
var refVal = s["ref"];
if (IndexOf(seenRefs, refVal) == -1) {
Push(seenRefs, refVal);
Push(uniqueRefs, { ref: refVal });
}
}
}
The above replaced the distinct
And lucky enough I was only filtering by a unique ref so the below worked for me on the filter, I have also asked our GIS people to log a case with Esri so hopefully there is a simple fix that will sort it.
for (var j = 0; j < Count(uniqueRefs); j++) {
var x = uniqueRefs[j]["ref"];
var filteredStats = [];
for (var k = 0; k < Count(statsArray); k++) {
var s = statsArray[k];
if (HasKey(s, "ref") && s["ref"] == x) {
Push(filteredStats, s);
}
}
Esri apparently fixed the bug and my code is working once again.
Thank you for the expression examples, it has helped us narrow down and isolate this issue. Just to clarify this was not an intended change in behavior. We're hoping to roll this out as a fix in the next few days. The bug itself impacts a few specific usage patterns of featureSets.