|
POST
|
You'll want to use an Arcade element instead of a text element to show clickable links. Here's one way to do this, which also uses template literals var p = Portal("https://arcgis.com");
var features = FeatureSetByPortalItem(p, "<feature ID>", 0, ["zone_name", "maintained_yn", "maintained_date", "Maint_Activity", "groups_involved", "notes", "picture"]);
var plot = $feature.Zone_Name;
var filterStatement = "zone_name = @plot";
var relatedData = Filter(features, filterStatement);
var relatedDataSorted = OrderBy(relatedData, "maintained_date ASC");
var popupString = "";
for (var f in relatedDataSorted) {
//var pic = f.picture;
popupString += `${text(f.maintained_date, "MM/DD/YYYY")}<br/>
Native Plant Zone: ${f.zone_name}<br/>
Maintained?: ${f.maintained_yn}<br/>
Maintenance Activity: ${f.Maint_Activity}<br/>
Groups Involved: ${f.groups_involved}<br/>
Notes: ${f.notes}<br/>
<a href="${f.picture}">Photo</a><br/><br/>`
}
return {
type : 'text',
text : popupString
}
... View more
06-10-2025
11:44 AM
|
1
|
1
|
502
|
|
POST
|
Good use of the Case statement in the GroupBy function. I always overlook that as a possible solution. I believe you'll still have to loop through the grouped Featureset to calculate the percentage. var investigated = "CASE WHEN Status = 'Investigated' THEN 1 ELSE 0 END";
var pending = "CASE WHEN Status = 'Pending' THEN 1 ELSE 0 END";
var grouped = Groupby(
fs,
["Person"],
[
{ name: "Total", expression: "Status", statistic: "COUNT" },
{ name: "Investigated", expression: investigated, statistic: "SUM" },
{ name: "Pending", expression: pending, statistic: "SUM" }
]
);
var fields = Schema(grouped).fields;
Push(fields, { name: "Percentage", type: "esriFieldTypeDouble" });
var features = [];
for (var g in grouped) {
push(
features,
{
attributes:
{
Total: g.Total,
Investigated: g.Investigated,
Pending: g.Pending,
Percentage: Round(g.Investigated / g.Total * 100)
}
}
);
}
return FeatureSet({ fields: fields, features: features });
... View more
06-09-2025
06:48 AM
|
0
|
0
|
417
|
|
POST
|
Use Javascript, since Arcade is based on that language.
... View more
06-06-2025
01:32 PM
|
1
|
0
|
914
|
|
POST
|
It looks like you'd just need to get the sum of the costamounts field in expendituresFS instead of using the most recent expenditure record. //budget values
var expendituresFS = FeatureSetByRelationshipName($feature, "Spending");
var actcost = Sum(expendituresFS , 'costamount')
var estCost = $feature.estcost;
var totalSpending = 0+ actcost //not sure why you need "0+" in this line
var budgetRemaining = estcost-actcost If you're going to post code, please use the Insert/Edit code sample button
... View more
06-06-2025
12:44 PM
|
1
|
2
|
932
|
|
POST
|
It doesn't look like there's a way to do that within the text element. Is there way to replicate what you have in the text element in an Arcade element instead?
... View more
06-06-2025
06:49 AM
|
0
|
1
|
1986
|
|
POST
|
That code should work perfectly fine. It works in the Playground with some testing data. You should look at one of the attributes in the related_data object to see if it changes (line 8 ) Console(feat.OBJECTID)
... View more
06-05-2025
12:40 PM
|
2
|
1
|
1164
|
|
POST
|
Here's one way to do that. I used a dummy dataset to test it out, so substitute your actual dataset. var fs = FeatureSet(
{
fields: [
{ alias: "Person", name: "Person", type: "esriFieldTypeString" },
{ alias: "Status", name: "Status", type: "esriFieldTypeString" }
],
features: [
{ attributes: { Person: "Person 1", Status: "Investigated" } },
{ attributes: { Person: "Person 1", Status: "Investigated" } },
{ attributes: { Person: "Person 1", Status: "Pending" } },
{ attributes: { Person: "Person 1", Status: "Investigated" } },
{ attributes: { Person: "Person 2", Status: "Investigated" } },
{ attributes: { Person: "Person 2", Status: "Pending" } },
{ attributes: { Person: "Person 2", Status: "Pending" } },
{ attributes: { Person: "Person 2", Status: "Pending" } },
{ attributes: { Person: "Person 2", Status: "Investigated" } },
{ attributes: { Person: "Person 2", Status: "Investigated" } },
{ attributes: { Person: "Person 3", Status: "Investigated" } },
{ attributes: { Person: "Person 3", Status: "Investigated" } },
{ attributes: { Person: "Person 3", Status: "Pending" } }
]
}
);
var statuses = ["Investigated", "Pending"];
var people = GroupBy(fs, "Person", { name: "Total", expression: "1", statistic: "Count" });
var peopleandstats = GroupBy(fs, ["Person", "Status"], { name: "Total", expression: "1", statistic: "Count" });
var features = [];
for (var p of people) {
var person = p.Person;
var attr = {};
attr["Person"] = person;
for (var status of statuses) {
var s = First(Filter(peopleandstats, "Person = @person AND Status = @status"));
attr[status] = s.Total;
if (status == "Investigated")
attr["Percentage"] = Round(s.Total / p.Total * 100, 0);
}
attr["Total"] = p.Total;
Push(features, { attributes: attr });
}
var fields = [
{ name: "Person", type: "esriFieldTypeString" },
{ name: "Investigated", type: "esriFieldTypeInteger" },
{ name: "Pending", type: "esriFieldTypeInteger" },
{ name: "Total", type: "esriFieldTypeInteger" },
{ name: "Percentage", type: "esriFieldTypeInteger" }
];
return FeatureSet({ fields: fields, features: features }); which returns this table
... View more
06-05-2025
06:46 AM
|
0
|
2
|
475
|
|
POST
|
You just need to make a minor change on line 23 var yearCounts = {}
// Count inspections by year
for (var f in fs) {
var inspDate = f["Inspect_Date"]
if (!IsEmpty(inspDate)) {
var year_1 = Text(Year(inspDate))
if (HasKey(yearCounts, year_1)) {
yearCounts[year_1] += 1
} else {
yearCounts[year_1] = 1
}
}
}
// Construct output features using Feature()
var features = []
for (var y in yearCounts) {
var attrs = {
"Year": y,
"Inspection_Count": yearCounts[y]
}
Push(features, {attributes: attrs})
}
// Return a proper FeatureSet
var schem = {
fields: [
{ name: "Year", type: "esriFieldTypeString" },
{ name: "Inspection_Count", type: "esriFieldTypeInteger" }
],
geometryType: "",
features: features
}
return FeatureSet(schem)
... View more
06-04-2025
09:16 AM
|
0
|
1
|
368
|
|
POST
|
Unfortunately, unlike ArcGIS Pro, you can't use formatting tags in a label in a web map. The way around that limitation would be to use a different label classes for each color. For example, these labels were created using two label classes The Deep label class uses the expression if ($feature.Depth_ft > 30) return $feature.Depth_ft while the Shallow label classes uses this expression if ($feature.Depth_ft <= 30) return $feature.Depth_ft
... View more
06-02-2025
07:12 AM
|
0
|
0
|
642
|
|
POST
|
Are the values Null, an empty string (""), or a space (" ")?
... View more
05-29-2025
09:00 AM
|
1
|
1
|
791
|
|
POST
|
You just need to convert day to a Text string to use it in the HasKey function (line 19). Note that your original line was "Weekday(dateVal) - 1", which is incorrect. The Weekday function returns the day using values ranging from 0 (Sunday) to 6 (Saturday). This also only counts that incidents that are outside the hours of 9 am and 5 pm (line 18) var portal = Portal("https://www.arcgis.com/");
var fs = Top(
FeatureSetByPortalItem(
portal,
"b7a7144cda9046a5bfc6b36fa88e0477",
0,
["DateTime"],
false
),
10
);
var dayCounts = { "0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0 };
for (var f in fs) {
var dateVal = f["DateTime"];
if (!IsEmpty(dateVal)) {
if (Hour(dateVal) < 9 || Hour(dateVal) >= 17) {
var day = Text(Weekday(dateVal));
if (HasKey(dayCounts, day)) {
dayCounts[day] += 1;
}
}
}
}
var outDict = {
fields: [
{ name: "Day", alias: "Day of Week", type: "esriFieldTypeInteger" },
{ name: "Count", alias: "Incident Count", type: "esriFieldTypeInteger" }
],
geometryType: "",
features: []
};
// Add the results as features
for (var k in dayCounts) {
Push(
outDict.features,
{ attributes: { Day: Number(k), Count: dayCounts[k] } }
);
}
return FeatureSet(Text(outDict));
... View more
05-29-2025
05:44 AM
|
1
|
1
|
332
|
|
POST
|
Here's one I use to concatenate fields. It uses GroupBy to get the required fields and counts, then creates a new featureset with the concatenated fields. My original dataset has the field Strat_Num, which is a unique combination of Habitat, Depth, Subregion, and Admin. I wanted to group by Stratum Number, concatenate the other values, and get their count. This is the code I came up with var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com/"),
"itemId",
0
);
var grouped = GroupBy(
fs,
"Strat_Num",
[
{ name: "Habitat", expression: "Habitat", statistic: "Max" },
{ name: "Depth", expression: "Depth", statistic: "Max" },
{ name: "SUBREGION", expression: "SUBREGION", statistic: "Max" },
{ name: "ADMIN", expression: "ADMIN", statistic: "Max" },
{ name: "Count", expression: "1", statistic: "Count" }
]
);
var features = [];
for (var i of grouped) {
Push(
features,
{
attributes:
{
Number: i.Strat_num,
Stratum: `${i.Habitat} ${i.Depth} ${i.SUBREGION} ${i.Admin}`,
Count: i.Count
}
}
);
}
return FeatureSet(
{
fields: [
{ name: "Number", type: "esriFieldTypeInteger" },
{ name: "Stratum", type: "esriFieldTypeString" },
{ name: "Count", type: "esriFieldTypeInteger" }
],
features: features
}
); which gives me this table
... View more
05-23-2025
11:41 AM
|
1
|
0
|
373
|
|
POST
|
Your logic works using this testing data, so I would use @ZenMasterZeke's suggestion to use Console (use the Run button to see the results in the Arcade window) to see what's not working // Replace with your actual Portal item IDs
var fuelItemID = "774019f31f8549c39b5c72f149bbe74e"; // states
var compItemID = "5f31109b46d541da86119bd4cf213848"; // zip codes
// Access both layers
var fuelLayer = FeatureSetByPortalItem(Portal("https://www.arcgis.com"), fuelItemID, 0, ["STATE_ABBR", "STATE_FIPS"],false);
console(fuelLayer)
var compLayer = FeatureSetByPortalItem(Portal("https://www.arcgis.com"), compItemID, 3, ["State", "POPULATION", "ZIP_CODE"],false);
console(compLayer)
// Array to store joined features
var joinedFeatures = [];
// Join loop
for (var fuel in fuelLayer) {
console(fuel["STATE_ABBR"])
var lid = fuel["STATE_ABBR"];
var match = First(Filter(compLayer, "State = @lid"));
if (!IsEmpty(match)) {
console(match["POPULATION"])
var attributes = {
COMPNO: fuel["STATE_FIPS"],
FUELLOADS: match["POPULATION"],
Plantation: match["ZIP_CODE"]
};
Push(joinedFeatures, {
attributes: attributes
});
}
}
// Define output FeatureSet schema
var fields = [
{ name: "COMPNO", type: "esriFieldTypeString" },
{ name: "FUELLOADS", type: "esriFieldTypeInteger" },
{ name: "Plantation", type: "esriFieldTypeString" },
{ name: "District", type: "esriFieldTypeString" },
{ name: "SuperDistrict", type: "esriFieldTypeString" }
];
// Return a proper FeatureSet
return FeatureSet({
fields: fields,
geometryType: "",
features: joinedFeatures
});
... View more
05-16-2025
12:11 PM
|
0
|
0
|
916
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | yesterday | |
| 1 | yesterday | |
| 1 | 12-18-2025 10:17 AM | |
| 2 | 12-17-2025 11:04 AM | |
| 1 | 11-18-2025 12:30 PM |
| Online Status |
Offline
|
| Date Last Visited |
8 hours ago
|