Hi,
I have a data expression (below) which executed properly when I was testing the data expression and configuring my chart in my Dashboard. After I saved and refreshed, it was no longer executing properly and does not show all of the data. Sometimes all data is returned, and other times it is not.
For example, this is what the chart should look like (it does look like this sometimes):
Then if I refresh, I see this:
Here is my data expression:
var portal = Portal("https://www.arcgis.com");
// Create a FeatureSet for stable and unstable inspections.
// Group the features by the BLA
var BLA = FeatureSetByPortalItem(portal,"###",0,['BLA_Used'],false);
var groupBLA = GroupBy(BLA,
["BLA_Used"],
[
{ name: "BoatLaunchArea", expression: "BLA_Used", statistic: "COUNT" },
]
);
var combinedDict = {
fields: [
{ name: "BLA", type: "esriFieldTypeString" },
{ name: "cntSurveyScans", type: "esriFieldTypeInteger" },
],
geometryType: "",
features: [],
};
var i = 0;
for (var m in groupBLA) {
combinedDict.features[i] = {
attributes: {
BLA: m["BLA_Used"],
cntSurveyScans: (m["BoatLaunchArea"] / 2),
},
};
i++;
}
return FeatureSet(Text(combinedDict));
This feature layer is updated frequently by Survey123. Could the frequent updates to the layer be causing these issues? This layer also has 8,000 records and counting.
Any advice would be appreciated!
Erica
Solved! Go to Solution.
I figured this out - the occasional decimal value was messing this up. The correct data expression now reads:
var portal = Portal("https://www.arcgis.com");
// Group the features by the BLA
var BLA = FeatureSetByPortalItem(portal,"xxx",0,['BLA_Used'],false);
var groupBLA = GroupBy(BLA,
["BLA_Used"],
[
{ name: "BoatLaunchArea", expression: "BLA_Used", statistic: "COUNT" },
]
);
var combinedDict = {
fields: [
{ name: "BLA", type: "esriFieldTypeString" },
{ name: "cntSurveyScans", type: "esriFieldTypeInteger" },
],
geometryType: "",
features: [],
};
var i = 0;
for (var m in groupBLA) {
combinedDict.features[i] = {
attributes: {
BLA: m["BLA_Used"],
cntSurveyScans: (Floor(m["BoatLaunchArea"] / 2)),
},
};
i++;
}
return FeatureSet(Text(combinedDict));
I figured this out - the occasional decimal value was messing this up. The correct data expression now reads:
var portal = Portal("https://www.arcgis.com");
// Group the features by the BLA
var BLA = FeatureSetByPortalItem(portal,"xxx",0,['BLA_Used'],false);
var groupBLA = GroupBy(BLA,
["BLA_Used"],
[
{ name: "BoatLaunchArea", expression: "BLA_Used", statistic: "COUNT" },
]
);
var combinedDict = {
fields: [
{ name: "BLA", type: "esriFieldTypeString" },
{ name: "cntSurveyScans", type: "esriFieldTypeInteger" },
],
geometryType: "",
features: [],
};
var i = 0;
for (var m in groupBLA) {
combinedDict.features[i] = {
attributes: {
BLA: m["BLA_Used"],
cntSurveyScans: (Floor(m["BoatLaunchArea"] / 2)),
},
};
i++;
}
return FeatureSet(Text(combinedDict));