Select to view content in your preferred language

Trying to do a Simple Data Split Data Expression in Dashboard

387
0
10-16-2023 09:13 PM
Labels (1)
JB3T
by
New Contributor

I figured out today that Attribute Expressions created in a WebMap do not make their way into Esri Dashboard.  I am wondering if someone can help me with a simple data expression.

1. I have a field called "FullAddress".  It is formatted as such "12 Main Street, Jonesville".

2. I can create an attribute expression in a WebMap to split "Jonesville" out into it's own virtual field.  The syntax for that is below.  It works fine in the WebMap.
  var CITY = Split($feature.FullAddress, ","); 
  
return Pop(CITY)

3. I wanted to be able to create a pie chart in a dashboard on "City" but low-and-behold, "City" is not available to me as it's a virtual field in the WebMap.  So, it appears I need a Data Expression in Dashboard.

4. I looked at samples and watched a ton of videos but I am just not able to get it to work in Dashboard.  FOr example, my data table has 3 fields...  OWNER, FULL_ADDRESS, and TYPE.  Per #2 above, I want to end up with OWNER, FULL_ADDRESS, CITY and TYPE.  "CITY" will come from the SPLIT code in #2.

5. Below is what I have.  Does anyone have an example that I can use?

var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '1234567', 0, ['OWNER', 'FullAddress', TYPE'], false);

var fsDict = {'fields': [
  •   { 'name': 'OWNER', 'type': 'esriFieldTypeString'},
      { 'name': 'FullAddress', 'type': 'esriFieldTypeString'},
      { 'name': 'TYPE', 'type': 'esriFieldTypeString'},
      { 'name': 'CITY', 'type': 'esriFieldTypeString'},
  ],
'geometryType': '',
'features': []};

var index = 0;
for (var feature in fs) {
    fsDict.features[index++] = {
      'attributes': {
        'FullAddress': feature['FullAddress'],
        }}}

return FeatureSet(text(fsDict));

I'm stuck but if I get this, I will be good from here on out!
0 Replies