Select to view content in your preferred language

Editing Data Expressions for List view in Dashboards

51
5
18 hours ago
Labels (1)
DeboMallick
Emerging Contributor

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. 

var fs1 = FeatureSetByPortalItem(Portal('PortalURL',0,['Event','Severity'],false); #polygon layer
var fs2 = FeatureSetByPortalItem(Portal('PortalURL',0,['Name','City'],false); #point layer
 
var b1 = Buffer(fs2, 10, 'miles')

var int1 = First(Intersects(fs1, b1))
 

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?

 
0 Kudos
5 Replies
AndreasHall
Esri Contributor

FeatureSetByPortalItem is not supported in Dashboards lists. Only the Core function bundle is supported (Dashboard List Formatting | ArcGIS Arcade | Esri Developer)

0 Kudos
DeboMallick
Emerging Contributor

Hi @AndreasHall . Seems that it is supported. 

In case of something like this

var fs1 = FeatureSetByPortalItem(Portal('PortalURL',0,['Event','Severity'],false); #polygon layer
 
return fs1;
 
I am able to see the features populated within the list view.
0 Kudos
DeboMallick
Emerging Contributor

And example would be (using a living atlas layer here)

var fs1FeatureSetByPortalItem(Portal('https://www.arcgis.com'),'a6134ae01aad44c499d12feec782b386',6,['Event', 'Severity','Certainty', 'Summary','Updated', 'Start', 'End_'], false);
 
return fs1;
0 Kudos
AndreasHall
Esri Contributor

Okay, I might be wrong. Arcade is not my field of expertise.

0 Kudos
NicoleJohnson
Regular Contributor

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))
0 Kudos