Combine multiple choices into one named choice

193
1
01-07-2022 12:34 PM
SayedWali
New Contributor III

I have four multiple choices that are unique grant numbers and want to combine two by two and give them new names. I have tried but as I am new to Arcade, couldn't manage to do it.  Any idea will be appreciated.

 

15-GR-1060CWD
20-GR-0040
16-GR-1053WAD
21-GR-3012

 

Here is what I have for now, but I want them as two separate categories, CWD and WAD:

SayedWali_0-1641587338785.png

 

Here is the expressions:

 

 

var portal = Portal('https://arcgis.com/');

var EODFAR = GroupBy(
    FeatureSetByPortalItem(portal,'49610a8451174e65b413509ff03196b4',0,['*'],false),
    ['field_1','fatype','field_82'],
    [
        { name: 'EODFAR_ID', expression: 'field_2', statistic: 'COUNT' },
        
    ],
    
);

var CWD = filter(EODFAR, "field_82 = '15-GR-1060' and field_82 = '20-GR-0040'");
var WAD = filter(EODFAR, "field_82 = '21-GR-3012' and field_82 = '16-GR-1053'");


var combinedDict = {
    fields: [
        { name: 'Choices_WAD_CWD', type: 'esriFieldTypeString' },
        { name: 'Report_date', type: 'esriFieldTypeDate' },
        { name: 'count_of_ids', type: 'esriFieldTypeInteger' },
        { name: 'advisors', type: 'esriFieldTypeString'},
    ],
    geometryType: '',
    features: [],
};

// Loop through each of the FeatureSets
var i = 0;
for (var f in EODFAR) {
    combinedDict.features[i] = {
        attributes: {
            
            Report_date: number(f['field_1']),
            advisors: f['fatype'],
            count_of_ids: f['EODFAR_ID'],
        },
    };
    i++;
}


// Return dictionary cast as a feature set 
return FeatureSet(Text(combinedDict));

 

 

@DavidNyenhuis1 

 

 

0 Kudos
1 Reply
natasha
New Contributor II

I don't have an answer, but am trying to do something similar in my dashboard so thanks for posting this

0 Kudos