Hi . I am trying to understand how to build a data expression for a list view in a dashboard where the output of two geometric expressions should pupulate into a FeatureSet. I am creating a buffer and intersect between two layers and if the condition satisfies, the output should return a text value within the FeatureSet.
This works while configuring pop ups but do not know how to populate this for a list view with dashboards.
Scripts looks something like this while configuring pop ups.
if(!IsEmpty(int1)) {
return Proper(`Affected by ${int1.Event}.`)
}
else {
return "Not affected by Event"
}
How would I show this output on a FeatureSet. Is this possible here?
FeatureSetByPortalItem is not supported in Dashboards lists. Only the Core function bundle is supported (Dashboard List Formatting | ArcGIS Arcade | Esri Developer).
Hi @AndreasHall . Seems that it is supported.
In case of something like this
And example would be (using a living atlas layer here)
Okay, I might be wrong. Arcade is not my field of expertise.
I think the problem/difference is that for your pop-ups, what's being returned is the result for one feature, whereas for your list, you need the whole featureset, so you need to store your results in a new featureset and return that featureset. You can use a dictionary to do this. The example shows a lot of options, but you don't need to actually set all those up. The basic way is to just set up your fields (in this case, I didn't need geometry):
var newDict = {fields: [
{name: 'NAME', type: 'esriFieldTypeString'},
{name: 'CENSUS0', type: 'esriFieldTypeInteger'},
{name: 'CENSUS1', type: 'esriFieldTypeInteger'},
{name: 'REGION', type: 'esriFieldTypeString'}],
geometryType: '',
features: []
}
After you create this, loop through the featureset(s) that are going to populate your new featureset. In this (heavily abbreviated) example, I wanted to add a "region" field to some ACS data on Living Atlas. This would be where your "affected by event"/"not affected by event" stuff goes:
for (var i in fsMI){ // This is the featureset I'm starting with, that doesn't have all the fields I need
var region
When(
i.NAME=="esrdfgbtdgbfd", region = '1',
i.NAME=="seihfirkesj", region = '8',
region = '0'
)
// Now that I have my regions, I can take the dictionary I created earlier and use it to fill my new featureset
Push(newDict['features'], {attributes: {NAME: i.NAME, CENSUS0: i[censusField0], CENSUS1: i[censusField1], REGION: region}})
}
var fsMINew = FeatureSet(Text(newDict))