I'm trying to come up with a data expression to create a bar graph to simply show the count (number of records) within 5 different data layers. The layers represent the same type of data, just range from records from 2020-2024.
I'd like to end up with something like this:
Thanks for any guidance!
Solved! Go to Solution.
There's a GitHub site that contains many different types of data expressions for Dashboard, including one showing how to combine different dataset.
Here's a script that combines two different dataset, each with a Date field. I'm selecting all the dates that aren't null to populate the table. You can expand this to your five data sets.
var portal = Portal("your portal");
var fs1 = FeatureSetByPortalItem(
portal,
"itemId for first dataset",
0,
["Date"],
false
);
var fs2 = FeatureSetByPortalItem(
portal,
"itemId for first dataset",
0,
["Date"],
false
);
var features = [];
var feat;
function populateFeatures(fs) {
for (var i in fs) {
if (!IsEmpty(i.Date)) {
feat = { attributes: { Year: Year(i.Date) } };
Push(features, feat);
}
}
}
var featureSets = [fs1, fs2]
for (var fs in featureSets) {
console(featureSets[fs])
populateFeatures(featureSets[fs]);
}
var combinedDict = {
fields: [{ name: "Year", type: "esriFieldTypeInteger" }],
geometryType: "",
features: features
};
return FeatureSet(combinedDict);
There's a GitHub site that contains many different types of data expressions for Dashboard, including one showing how to combine different dataset.
Here's a script that combines two different dataset, each with a Date field. I'm selecting all the dates that aren't null to populate the table. You can expand this to your five data sets.
var portal = Portal("your portal");
var fs1 = FeatureSetByPortalItem(
portal,
"itemId for first dataset",
0,
["Date"],
false
);
var fs2 = FeatureSetByPortalItem(
portal,
"itemId for first dataset",
0,
["Date"],
false
);
var features = [];
var feat;
function populateFeatures(fs) {
for (var i in fs) {
if (!IsEmpty(i.Date)) {
feat = { attributes: { Year: Year(i.Date) } };
Push(features, feat);
}
}
}
var featureSets = [fs1, fs2]
for (var fs in featureSets) {
console(featureSets[fs])
populateFeatures(featureSets[fs]);
}
var combinedDict = {
fields: [{ name: "Year", type: "esriFieldTypeInteger" }],
geometryType: "",
features: features
};
return FeatureSet(combinedDict);