Hello All,
I have created a Dashboard on my Portal. The layers I am referencing for the Dashboard are found in a map which is also included in the portal. I need to create a Table Widget that pulls field from two different layers within the map. I am attempting to use a Data Expression to retrieve the data from the two layers. I am just beginning to learn Arcade but I am pretty sure I am on the right track with the expression below; however, no matter how many times I have tried to correct an syntax errors within the expression I allows receive a message stating stating "Unable to execute the Arcade Script". I can't even get a simple expression to work.
1. Are there any specific permissions on the Portal that need to be enable to use Data Expressions withing a dashboard?
Here is the current expression. I am pulling from two layer 'Ownership Parcels' and 'Site Boundary'. From the 'Ownership Parcels' layer I need the following fields: 'COST_CENTER', 'Name', and 'CalculatedAcre'. From the 'Site Boundary' layer I need the these two field: 'Name' and 'COST_CENTER'. 'COST_CENTER' is the field that will link the two layers. Any advice would be appreciated!
// Connect to the same portal as your dashboard
var portal = Portal("https://some.portal.college.edu/portal")
// Shared item ID for both layers
var itemId = "4b1aefe40a8847bab37217a36688dfbf"
// Ownership Parcels (Layer 24)
var parcels = FeatureSetByPortalItem(
portal, itemId, 24,
["Name", "CalculatedArea", "COST_CENTER"]
)
// Site Boundary (Layer 57)
var sites = FeatureSetByPortalItem(
portal, itemId, 57,
["Name", "COST_CENTER"]
)
// Define table schema
var fields = [
{ name: "Parcel_Name", type: "esriFieldTypeString" },
{ name: "Calculated_Area", type: "esriFieldTypeDouble" },
{ name: "Parcel_COST_CENTER", type: "esriFieldTypeString" },
{ name: "Site_Name", type: "esriFieldTypeString" },
{ name: "Site_COST_CENTER", type: "esriFieldTypeString" }
]
// List of output features
var features = []
// Intersect parcels with sites and build output table
for (var parcel in parcels) {
for (var site in sites) {
if (Intersects(parcel, site)) {
Push(features, {
attributes: {
Parcel_Name: parcel["Name"],
Calculated_Area: parcel["CalculatedArea"],
Parcel_COST_CENTER: parcel["COST_CENTER"],
Site_Name: site["Name"],
Site_COST_CENTER: site["COST_CENTER"]
}
})
}
}
}
// Return result (dictionary structure — required by Dashboards)
return {
fields: fields,
geometryType: "",
features: features
}
Like this? Thank you for all your help!
for (var parcel in parcels) {Console(parcel.name)
I am still seeing the stuck circled. Also do I need to Intersect the parcels (see line 31). I really just want to join the 'Site Boundary' table to the 'Ownership Parcels' table.
Thanks again!