POST
|
You have to specify that using the FeatureSetByPortalItem function. var fs = FeatureSetByPortalItem(Portal('yourPortalUrl'), 'yourItemId', 0, ['S_CanConne_', 'S_Reserved', 'S_DesWpro'], false);
var Canc = Sum(fs, "S_CanConne_");
var Reserved = Sum(fs, "S_Reserved");
var DeswPro = Sum(fs, "S_DesWpro");
return FeatureSet(
{
fields: [
{ alias: "Can Connect", name: "CanConnect", type: "esriFieldTypeInteger" },
{ alias: "Reserved", name: "Reserved", type: "esriFieldTypeInteger" },
{ alias: "DeswPro", name: "DeswPro", type: "esriFieldTypeInteger" },
{ alias: "Total", name: "Total", type: "esriFieldTypeInteger" }
],
features: [
{
attributes:
{
CanConnect: CanC,
Reserved: Reserved,
DeswPro: DeswPro,
Total: CanC + Reserved + DeswPro
}
}
]
}
);
... View more
yesterday
|
0
|
0
|
27
|
POST
|
First, if you're going to post code, please use the Insert/Edit code sample button. That makes it easier to read the code and copy it to test it. Second, you haven't created the FeatureSet fs to get your sums. Third, a data expression has to return a FeatureSet to be used in a indicator, table, or gauge. To show the total of the sums in an indicator, you could use this return (using the rest of your code) return FeatureSet(
{
fields: [{ alias: "Total", name: "Total", type: "esriFieldTypeInteger" }],
features: [{ attributes: { Total: total } }]
}
); You could create a table with this return return FeatureSet(
{
fields: [
{ alias: "Can Connect", name: "CanConnect", type: "esriFieldTypeInteger" },
{ alias: "Reserved", name: "Reserved", type: "esriFieldTypeInteger" },
{ alias: "DeswPro", name: "DeswPro", type: "esriFieldTypeInteger" },
{ alias: "Total", name: "Total", type: "esriFieldTypeInteger" }
],
features: [
{
attributes:
{
CanConnect: CanC,
Reserved: Reserved,
DeswPro: DeswPro,
Total: total
}
}
]
}
);
... View more
yesterday
|
0
|
2
|
55
|
POST
|
What do you get when you return RoadLeft? Your code seems to work in the Playground, returning the value for the IsEmpty check. That is expected, since I doubt the testing FeatureSet and $feature intersect at all The reason you're getting "error0" is that the Geometry function expects a Feature, not a FeatureSet. You'd have to loop through the FeatureSet to test each Feature. var fsNbrhd = FeatureSetByName($datastore, 'Neighborhood', ['Nbrhd_Comm'], true);
for (var f in fsNbrhd) {
if (IsEmpty(Geometry(f))) return `Record ${f.OJBECTID) is empty";
}
return "No empty records"; What's curious is that putting the FeatureSet in the Geometry function works in ArcGIS Pro but not in the Playground. **Update I did test your code using my data in ArcGIS Pro and it did run correctly.
... View more
yesterday
|
1
|
0
|
34
|
POST
|
The post you referenced uses that code in a data expression to create a FeatureSet, which is used in the indicator. The profile for this functionality contains the Data access bundle, which includes the Portal and FeatureSet functions. It looks like there's a missing bundle in the documentation, since you can use the FeatureSetByPortalItem function in a data expression also. However, you're using this code in the advanced formatting section, which doesn't include the Data access bundle in its formatting profile.
... View more
yesterday
|
1
|
0
|
39
|
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
Tuesday
|
1
|
1
|
66
|
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
Monday
|
0
|
0
|
37
|
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
Friday
|
1
|
2
|
152
|
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
|
0
|
1
|
89
|
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
Thursday
|
2
|
1
|
318
|
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
Thursday
|
0
|
2
|
95
|
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
a week ago
|
0
|
1
|
92
|
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
a week ago
|
0
|
0
|
96
|
Title | Kudos | Posted |
---|---|---|
1 | yesterday | |
1 | yesterday | |
1 | Tuesday | |
2 | Tuesday | |
1 | Friday |
Online Status |
Offline
|
Date Last Visited |
yesterday
|