Select to view content in your preferred language

My Dictionary in Data Expression returns Null Values in field

826
2
Jump to solution
09-08-2023 01:49 PM
MlondiNdlovu1
Emerging Contributor

I have just started using arcade, I'm attempting to create a dictionary so I can reclassify the ages into groups (from a hosted feature layer), but my dictionary comes up empty. Below is the arcade code:

var ages = FeatureSetByPortalItem(
    Portal('//myportallink'),
    '//itemid', 
    0,
    ['*'],
    false);

// return ages

// create empty dictionary
var out_dict = {
    fields: [
        {name: 'age', alias: 'age', type: 'esriFieldTypeInteger'},
        {name: 'age_group', alias: 'age_group', type: 'esriFieldTypeString'},
    ],
    geometryType: '',
    features: []
}

// //loop through and populate the dictionary
var index = 0

for(var p in ages) {
    out_dict.features[index++] = {
        attirbutes : {
            age: number(p['app_age_id']),
            age_group:when(
                 0 >= p['app_age_id'] <= 14, '0-14',
                 15 >= p['app_age_id'] <= 24, '15-24',
                 25 >= p['app_age_id'] <= 54, '25-54',
                 55 >= p['app_age_id'] <= 64, '55-64',
                 p['app_age_id'] >= 65, '65+',
                  '')
      }
    }
};

return FeatureSet(text(out_dict))

When I test this, the result looks like this:

MlondiNdlovu1_0-1694205889934.png

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You have a typo on line 25 "attirbutes" instead of "attributes"

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

You have a typo on line 25 "attirbutes" instead of "attributes"

MlondiNdlovu1
Emerging Contributor

Thank you. I did not notice. fixed!!

0 Kudos