<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311600#M8163</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;Thank you for your help on this! I was wondering if you had any insights in the second part of the code I am working on to get the&amp;nbsp;&lt;STRONG&gt;desired result&amp;nbsp;&lt;/STRONG&gt;table from my initial post. My code below returns a dictionary counting the occurrences of the respective values across the whole dataset, I would instead like a table with the unique counts for occurrences within the specific fields. I imagine I will have to change the value_counts dictionary to include a sub-dictionary or list within each of the values, and then somehow populate that within the loop for each i in fields?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//create dictionary of possible values setting default count at 0
var value_counts = {
    "transportation": 0,
    "jobs": 0,
    "housing":0,
    "sustainability":0,
    "historical":0,
    "parks":0
}

//list of unique fields to get counts for each of the values
var fields = ["first_choice", "second_choice", "third_choice","fourth_choice","fifth_choice","sixth_choice"]

//loop through rows in feature that contain the text 1st, 2nd, 3rd choice etc.
for(var a in fs_dict) {
    //loop through each field that needs to be counted within that feature
    for(var i in fields) {
        var value = a[fields[i]]
        //add 1 to value counts for each time the feature exists??
        if(IsEmpty(value)) { continue }
        if(!HasKey(value_counts, value)) { value_counts[value] = 0 }
        value_counts[value] = value_counts[value] + 1
    }
}

var out_fs = {
    geometryType: "",
    fields: [
        {name: "Choice", type: "esriFieldTypeString"},
        {name: "Count", type: "esriFieldTypeInteger"},
    ],
    features: []
}
//return a dictionary of each possible value with their respective count
for(var v in value_counts) {
    var c = value_counts[v]
    var m = {attributes: {Choice: v, Count: c}}
    Push(out_fs.features, m)
}
return out_fs
return Featureset(Text(out_fs))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2023 16:39:34 GMT</pubDate>
    <dc:creator>MatthewBrandt</dc:creator>
    <dc:date>2023-07-25T16:39:34Z</dc:date>
    <item>
      <title>Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311295#M8157</link>
      <description>&lt;P&gt;Hello, I am trying to display some survey results in a dashboard. The question is ranked choice and I'm trying to replicate the chart shown in Survey123 Analyze -- where it gets the average "score" for each of the ranked choices. I have not been able to embed the analyze results in a way that I like, so now I'm trying to replicate using data expressions. The end result I'm looking for is a dictionary/array with a row for each of the unique choices, a column for each of the ranks, and a count in each field representing how many times that choice was ranked that number, as well as a final column representing the average. Below is an example of the input data&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;FeatureID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;RankChoiceList&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;1&lt;/TD&gt;&lt;TD width="50%"&gt;Apple,Banana,Orange&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;2&lt;/TD&gt;&lt;TD width="50%"&gt;Apple,Orange,Banana&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;3&lt;/TD&gt;&lt;TD width="50%"&gt;Orange,Apple,Banana&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;4&lt;/TD&gt;&lt;TD width="50%"&gt;Banana,Apple,Orange&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;5&lt;/TD&gt;&lt;TD width="50%"&gt;Apple,Banana,Orange&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now an example of the desired result, the average is calculated by: [(1st Choice Count * 3) + (2nd Choice Count * 2) + (3rd Choice Count * 1)] / [# of Features]&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%" height="24px"&gt;&lt;STRONG&gt;Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;&lt;STRONG&gt;1st Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;&lt;STRONG&gt;2nd Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;&lt;STRONG&gt;3rd Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;&lt;STRONG&gt;Average&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="24px"&gt;Apple&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;3&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;0&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2.6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="24px"&gt;Banana&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;1&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;1.8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="24px"&gt;Orange&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;1&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;1&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;3&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;1.6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now for the Arcade, this is my thought process followed by what I have so far:&lt;/P&gt;&lt;P&gt;First I'd like to split the RankChoiceList Column into three columns (1st, 2nd and 3rd) where the order of the comma-separated values matters -- first value in the 1st choice, second value in the 2nd choice, etc..&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;&lt;STRONG&gt;FeatureID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;&lt;STRONG&gt;1st Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;&lt;STRONG&gt;2nd Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;&lt;STRONG&gt;3rd Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;1&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Apple&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Banana&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Orange&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;2&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Apple&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Orange&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Banana&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;3&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Orange&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Apple&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Banana&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;4&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Banana&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Apple&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Orange&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px"&gt;5&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Apple&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Banana&lt;/TD&gt;&lt;TD width="25%" height="24px"&gt;Orange&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I would like to get counts of each of the unique choices for every rank (a total of 3 tables for each of the three choices)&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;&lt;STRONG&gt;Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;&lt;STRONG&gt;1st Choice&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Apple&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Banana&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Orange&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I'd like to combine these tables and calculate the average -- resulting in the&amp;nbsp;&lt;STRONG&gt;desired result&lt;/STRONG&gt; table from above.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have laid out my whole thought process in case there are suggestions of ways to do it better, however I am stuck on the first step. My code below returns a dictionary with the appropriate number of features and appropriate fields, but all of them return the same feature (objectId 19 and the corresponding ranks)&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Reference layer using the FeatureSetByPortalItem() function. 
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '2284118eba59466e9169133c458ef9d4' , 0, ['nodes','character_qualities','development_priorities','objectid'], false);

// Empty dictionary to capture each hazard reported as separate rows. 
var choicesDict = {'fields': [{'name':'oid','type':'esriFieldTypeString'},{ 'name': 'split_choices', 'type': 'esriFieldTypeString'},{ 'name': 'first_choice', 'type': 'esriFieldTypeString'},{ 'name': 'second_choice', 'type': 'esriFieldTypeString'},{ 'name': 'third_choice', 'type': 'esriFieldTypeString'},{ 'name': 'fourth_choice', 'type': 'esriFieldTypeString'},{ 'name': 'fifth_choice', 'type': 'esriFieldTypeString'},{ 'name': 'sixth_choice', 'type': 'esriFieldTypeString'}], 
                    'geometryType': '', 'features': []}; 

var index = 0; 

// Split comma separated hazard types and store in dictionary.  
for (var feature in fs) { 
    var split_array  =  Split(feature["development_priorities"], ',') 
    var count_arr = Count(fs) 
    for(var i = 0; i &amp;lt; count_arr; i++ ){ 
        choicesDict.features[i] = { 
            'attributes': { //'split_choices': Trim(split_array[i]),  
            'first_choice':split_array[0],'oid':feature.objectid,'second_choice':split_array[1],'third_choice':split_array[2],'fourth_choice':split_array[3],'fifth_choice':split_array[4],'sixth_choice':split_array[5]}} 
}} 
return choicesDict&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MatthewBrandt_0-1690241913065.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/76184iD12FF922FB69CE61/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MatthewBrandt_0-1690241913065.png" alt="MatthewBrandt_0-1690241913065.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My question is: how can I modify my code to successfully translate the choices into the appropriate columns and/or what would be a better way to do this?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 23:38:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311295#M8157</guid>
      <dc:creator>MatthewBrandt</dc:creator>
      <dc:date>2023-07-24T23:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311514#M8159</link>
      <description>&lt;P&gt;What's happening is that as you loop through each feature, in line 14 you are rewriting all the records in the dictionary for the current feature's attributes. Remove that loop and each dictionary record will have the correct attributes. I removed that loop and used the index variable as a counter instead of i. Also, don't use "feature" as a variable, since it is a &lt;A href="https://developers.arcgis.com/arcade/guide/reserved/" target="_self"&gt;reserved word&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Reference layer using the FeatureSetByPortalItem() function. 
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '2284118eba59466e9169133c458ef9d4' , 0, ['nodes','character_qualities','development_priorities','objectid'], false);

// Empty dictionary to capture each hazard reported as separate rows. 
var choicesDict = {'fields': [{'name':'oid','type':'esriFieldTypeString'},{ 'name': 'split_choices', 'type': 'esriFieldTypeString'},{ 'name': 'first_choice', 'type': 'esriFieldTypeString'},{ 'name': 'second_choice', 'type': 'esriFieldTypeString'},{ 'name': 'third_choice', 'type': 'esriFieldTypeString'},{ 'name': 'fourth_choice', 'type': 'esriFieldTypeString'},{ 'name': 'fifth_choice', 'type': 'esriFieldTypeString'},{ 'name': 'sixth_choice', 'type': 'esriFieldTypeString'}], 
                    'geometryType': '', 'features': []}; 

var index = 0; 

// Split comma separated hazard types and store in dictionary.  
for (var f in fs) { 
    console(f.objectid, f["development_priorities"])
    var split_array  =  Split(f["development_priorities"], ',') 
    var count_arr = Count(fs) 
    //for(var i = 0; i &amp;lt; count_arr; i++ ){ 
        choicesDict.features[index] = { 
            'attributes': { //'split_choices': Trim(split_array[i]),  
            'first_choice':split_array[0],'oid':f.objectid,'second_choice':split_array[1],'third_choice':split_array[2],'fourth_choice':split_array[3],'fifth_choice':split_array[4],'sixth_choice':split_array[5]}} 
    //}
    index++;
} 
return choicesDict&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 14:19:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311514#M8159</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-07-25T14:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311600#M8163</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;Thank you for your help on this! I was wondering if you had any insights in the second part of the code I am working on to get the&amp;nbsp;&lt;STRONG&gt;desired result&amp;nbsp;&lt;/STRONG&gt;table from my initial post. My code below returns a dictionary counting the occurrences of the respective values across the whole dataset, I would instead like a table with the unique counts for occurrences within the specific fields. I imagine I will have to change the value_counts dictionary to include a sub-dictionary or list within each of the values, and then somehow populate that within the loop for each i in fields?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//create dictionary of possible values setting default count at 0
var value_counts = {
    "transportation": 0,
    "jobs": 0,
    "housing":0,
    "sustainability":0,
    "historical":0,
    "parks":0
}

//list of unique fields to get counts for each of the values
var fields = ["first_choice", "second_choice", "third_choice","fourth_choice","fifth_choice","sixth_choice"]

//loop through rows in feature that contain the text 1st, 2nd, 3rd choice etc.
for(var a in fs_dict) {
    //loop through each field that needs to be counted within that feature
    for(var i in fields) {
        var value = a[fields[i]]
        //add 1 to value counts for each time the feature exists??
        if(IsEmpty(value)) { continue }
        if(!HasKey(value_counts, value)) { value_counts[value] = 0 }
        value_counts[value] = value_counts[value] + 1
    }
}

var out_fs = {
    geometryType: "",
    fields: [
        {name: "Choice", type: "esriFieldTypeString"},
        {name: "Count", type: "esriFieldTypeInteger"},
    ],
    features: []
}
//return a dictionary of each possible value with their respective count
for(var v in value_counts) {
    var c = value_counts[v]
    var m = {attributes: {Choice: v, Count: c}}
    Push(out_fs.features, m)
}
return out_fs
return Featureset(Text(out_fs))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 16:39:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311600#M8163</guid>
      <dc:creator>MatthewBrandt</dc:creator>
      <dc:date>2023-07-25T16:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311709#M8166</link>
      <description>&lt;P&gt;If I'm understanding your objective correctly, you want to get a table of each item and the number of times it's been selected for each of the six rankings. Since you only working with the attributes of the development priorities field for the second part of your code, I've rewritten most of your code from the first example to return just an array of arrays. Each array is a separate response, split into the six choices. You don't need a dictionary here containing the geometry information. It makes it easier to get the final table, which is a dictionary of dictionaries.&lt;/P&gt;&lt;P&gt;Each item in the dictionary of choices (transportation, jobs, etc) has a dictionary of how many times it was chosen at each rank (First choice, second choice, etc).&lt;/P&gt;&lt;P&gt;Is this what you're looking for?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '2284118eba59466e9169133c458ef9d4' , 0, ['development_priorities'], false);
var choicesArray = []

// Split comma separated hazard types and store in array.  
for (var f in fs) { 
    var split_array = Split(f["development_priorities"], ',');
    var choiceArray = []
    for (var index in split_array) push(choiceArray, split_array[index]);
    push(choicesArray, choiceArray); //add this to final array     
}

//Dictionary of rank counts for each choice
var value_counts = {
    "transportation": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "jobs": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "housing": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "sustainability": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "historical": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "parks": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0}
};

for (var a in choicesArray) {
    var choices = choicesArray[a]
    for(var i in choices) {
        var value = choices[i]
        //add 1 to value counts for each time the feature exists??
        
        if(IsEmpty(value)) { continue }
          //if(!HasKey(value_counts, value)) { value_counts[value][i] = 0 } ignoring non-present values for now
        if (i == 0) value_counts[value]['First Choice'] = value_counts[value]['First Choice'] + 1
        if (i == 1) value_counts[value]['Second Choice'] = value_counts[value]['Second Choice'] + 1
        if (i == 2) value_counts[value]['Third Choice'] = value_counts[value]['Third Choice'] + 1 
        if (i == 3) value_counts[value]['Fourth Choice'] = value_counts[value]['Fourth Choice'] + 1 
        if (i == 4) value_counts[value]['Fifth Choice'] = value_counts[value]['Fifth Choice'] + 1 
        if (i == 5) value_counts[value]['Sixth Choice'] = value_counts[value]['Sixth Choice'] + 1           
    }
}
return value_counts&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="choices.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/76286i1806F1DBA8BA8791/image-size/medium?v=v2&amp;amp;px=400" role="button" title="choices.png" alt="choices.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 19:28:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311709#M8166</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-07-25T19:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311750#M8167</link>
      <description>&lt;P&gt;And here's a slightly more efficient way of doing that. There's no need to create the choicesArray array once then loop through it again.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '2284118eba59466e9169133c458ef9d4' , 0, ['development_priorities'], false);

//Dictionary of rank counts for each choice
var value_counts = {
    "transportation": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "jobs": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "housing": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "sustainability": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "historical": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "parks": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0}
};

// Split comma separated hazard types and store in array.  
for (var f in fs) { 
    var split_array = Split(f["development_priorities"], ',');
    var choiceArray = []
    for (var index in split_array) push(choiceArray, split_array[index]);

    for(var i in choiceArray) {
        var value = choiceArray[i]
        //add 1 to value counts for each time the feature exists??
        
        if(IsEmpty(value)) { continue }
          //if(!HasKey(value_counts, value)) { value_counts[value][i] = 0 } ignoring non-present values for now
        console(value, i, value_counts)
        if (i == 0) value_counts[value]['First Choice'] = value_counts[value]['First Choice'] + 1
        if (i == 1) value_counts[value]['Second Choice'] = value_counts[value]['Second Choice'] + 1
        if (i == 2) value_counts[value]['Third Choice'] = value_counts[value]['Third Choice'] + 1 
        if (i == 3) value_counts[value]['Fourth Choice'] = value_counts[value]['Fourth Choice'] + 1 
        if (i == 4) value_counts[value]['Fifth Choice'] = value_counts[value]['Fifth Choice'] + 1 
        if (i == 5) value_counts[value]['Sixth Choice'] = value_counts[value]['Sixth Choice'] + 1   
    }
}
return value_counts&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Jul 2023 20:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311750#M8167</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-07-25T20:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311775#M8168</link>
      <description>&lt;P&gt;Yes! Thank you. This is exactly what I was looking for. In case you were curious, I also was looking for a weighted "average" to compare the ranks which I was able to successfully do by appending this last bit of code. This returns the same results as the Analyze tab in Survey123 which is what I was trying to replicate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Reference layer using the FeatureSetByPortalItem() function. 
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '2284118eba59466e9169133c458ef9d4' , 0, ['development_priorities'], false);
var choicesArray = []
//return fs
// Split comma separated hazard types and store in array.  
for (var f in fs) { 
    var split_array = Split(f["development_priorities"], ',');
    var choiceArray = []
    for (var index in split_array) push(choiceArray, split_array[index]);
    push(choicesArray, choiceArray); //add this to final array     
}

//return choicesArray

//Dictionary of rank counts for each choice
// NEW Add Average to each array
var value_counts = {
    "transportation": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average' : 0},
    "jobs": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average': 0},
    "housing": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average':0},
    "sustainability": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average':0},
    "historical": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average':0},
    "parks": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average':0}
};

for (var a in choicesArray) {
    var choices = choicesArray[a]
    for(var i in choices) {
        var value = choices[i]
        //add 1 to value counts for each time the feature exists??
        
        if(IsEmpty(value)) { continue }
          //if(!HasKey(value_counts, value)) { value_counts[value][i] = 0 } ignoring non-present values for now
        if (i == 0) value_counts[value]['First Choice'] = value_counts[value]['First Choice'] + 1
        if (i == 1) value_counts[value]['Second Choice'] = value_counts[value]['Second Choice'] + 1
        if (i == 2) value_counts[value]['Third Choice'] = value_counts[value]['Third Choice'] + 1 
        if (i == 3) value_counts[value]['Fourth Choice'] = value_counts[value]['Fourth Choice'] + 1 
        if (i == 4) value_counts[value]['Fifth Choice'] = value_counts[value]['Fifth Choice'] + 1 
        if (i == 5) value_counts[value]['Sixth Choice'] = value_counts[value]['Sixth Choice'] + 1           
    }
}

// NEW Get average value and append

for (var a in value_counts) {
    value_counts[a]['Average']=(value_counts[a]['First Choice']*6+value_counts[a]['Second Choice']*5+value_counts[a]['Third Choice']*4+value_counts[a]['Fourth Choice']*3+value_counts[a]['Fifth Choice']*2+value_counts[a]['Sixth Choice'])/Count(fs)
}

return value_counts&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Jul 2023 20:52:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1311775#M8168</guid>
      <dc:creator>MatthewBrandt</dc:creator>
      <dc:date>2023-07-25T20:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1314404#M8203</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;So this works to create a dictionary representing the data I need, but I am not able to successfully convert into a featureSet for use within dashboards. I believe I need to add the relevant fields that would be in the JSON, and add the dictionary essentially as features -- but I'm having trouble doing this. I'll attach my code, but it is not successfully replicating the dictionary nor is it able to be converted to a featureset using the FeatureSet() function.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//SECOND ATTEMPT: this time trying to add directly to a fs compatible dicitonary

var fs1 = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '2284118eba59466e9169133c458ef9d4' , 0, ['development_priorities'], false);
var choicesArray1 = []
// return fs
// Split comma separated hazard types and store in array.  
for (var f in fs1) { 
    var split_array1 = Split(f["development_priorities"], ',');
    var choiceArray1 = []
    for (var index in split_array1) push(choiceArray1, split_array1[index]);
    push(choicesArray1, choiceArray1); //add this to final array     
}
//return(choicesArray1)

var valuecounts1={
    'fields':[
        {'name':'First Choice','type':'esriFieldTypeInteger'},
        {'name':'Second Choice','type':'esriFieldTypeInteger'},
        {'name':'Third Choice','type':'esriFieldTypeInteger'},
        {'name':'Fourth Choice','type':'esriFieldTypeInteger'},
        {'name':'Fifth Choice','type':'esriFieldTypeInteger'},
        {'name':'Sixth Choice','type':'esriFieldTypeInteger'},
        {'name':'Quality','type':'esriFieldTypeString'},
        {'name':'Average','type':'esriFieldTypeFloat'}
    ],
    'geometryType':'',
    'features':[]
};

//return(valuecounts1)

valuecounts1.features[0]= {'Quality':"transportation",'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average' : 0}
valuecounts1.features[1]= {'Quality':"jobs",'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average': 0}
valuecounts1.features[2]= {'Quality':"housing",'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average':0}
valuecounts1.features[3]= {'Quality':"sustainability",'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average':0}
valuecounts1.features[4]= {'Quality':"historical",'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average':0}
valuecounts1.features[5]= {'Quality':"parks",'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0,'Average':0}


//return(valuecounts1)
for (var a in choicesArray1) { //for each feature within the dataset
    var choices = choicesArray1[a] //set choices as a variable representing the current feature which has 6 fields, a field for each choice
    for(var i in choices) { //for each field within the current feature, rank 1, rank 2, etc..
        var value = choices[i] //set value as the field within the feature
        //add 1 to value counts for each time the feature exists??
        var vcf = valuecounts1.features[i]
        var vcfq = vcf['Quality']
        //return(vcf['Quality'])
        if(IsEmpty(value)) { continue }
        if(vcfq == value) {
          //if(!HasKey(value_counts, value)) { value_counts[value][i] = 0 } ignoring non-present values for now
        if (i == 0) vcf['First Choice'] = vcf['First Choice'] + 1
        if (i == 1) vcf['Second Choice'] = vcf['Second Choice'] + 1
        if (i == 2) vcf['Third Choice'] = vcf['Third Choice'] + 1 
        if (i == 3) vcf['Fourth Choice'] = vcf['Fourth Choice'] + 1 
        if (i == 4) vcf['Fifth Choice'] = vcf['Fifth Choice'] + 1 
        if (i == 5) vcf['Sixth Choice'] = vcf['Sixth Choice'] + 1 
    }
    }
}
return(valuecounts1)
//Console(valuecounts1)
// var fs2 = FeatureSet(Text(valuecounts1))
// return fs2

// NEW Get average value and append
for (var a in valuecounts1) {
    vcf=valuecounts1.features[a]
    vcf['Average']=(valuecounts1.features[a]['First Choice']*6+valuecounts1.features[a]['Second Choice']*5+valuecounts1.features[a]['Third Choice']*4+valuecounts1.features[a]['Fourth Choice']*3+valuecounts1.features[a]['Fifth Choice']*2+valuecounts1.features[a]['Sixth Choice'])/Count(fs1)
}

return(valuecounts1)
Console(valuecounts1)
var fs2 = FeatureSet(Text(valuecounts1))
return fs2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 00:21:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1314404#M8203</guid>
      <dc:creator>MatthewBrandt</dc:creator>
      <dc:date>2023-08-02T00:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Use Arcade Data Expressions to split Ranked Choice Fields into Separate Columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1315605#M8216</link>
      <description>&lt;P&gt;This code works&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '2284118eba59466e9169133c458ef9d4' , 0, ['development_priorities'], false);

//Dictionary of rank counts for each choice
var value_counts = {
    "transportation": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "jobs": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "housing": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "sustainability": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "historical": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0},
    "parks": {'First Choice': 0,'Second Choice' : 0,'Third Choice' : 0,'Fourth Choice' : 0,'Fifth Choice' : 0,'Sixth Choice' : 0}
};

// Split comma separated hazard types and store in array.  
for (var f in fs) { 
    var split_array = Split(f["development_priorities"], ',');
    var choiceArray = []
    for (var index in split_array) push(choiceArray, split_array[index]);

    for(var i in choiceArray) {
        var value = choiceArray[i]
        //add 1 to value counts for each time the feature exists??
        
        if(IsEmpty(value)) { continue }
          //if(!HasKey(value_counts, value)) { value_counts[value][i] = 0 } ignoring non-present values for now
          //console(value, i, value_counts)
        if (i == 0) value_counts[value]['First Choice'] = value_counts[value]['First Choice'] + 1
        if (i == 1) value_counts[value]['Second Choice'] = value_counts[value]['Second Choice'] + 1
        if (i == 2) value_counts[value]['Third Choice'] = value_counts[value]['Third Choice'] + 1 
        if (i == 3) value_counts[value]['Fourth Choice'] = value_counts[value]['Fourth Choice'] + 1 
        if (i == 4) value_counts[value]['Fifth Choice'] = value_counts[value]['Fifth Choice'] + 1 
        if (i == 5) value_counts[value]['Sixth Choice'] = value_counts[value]['Sixth Choice'] + 1   
    }
}
for (var a in value_counts) {
    value_counts[a]['Average']=(value_counts[a]['First Choice']*6+value_counts[a]['Second Choice']*5+value_counts[a]['Third Choice']*4+value_counts[a]['Fourth Choice']*3+value_counts[a]['Fifth Choice']*2+value_counts[a]['Sixth Choice'])/Count(fs)
}

var Dict = {  
  'fields': [
   { 'name': 'Quality', 'type': 'esriFieldTypeString' },  
   { 'name': 'Average','type': 'esriFieldTypeDouble'},  
   { 'name': 'First Choice','type': 'esriFieldTypeInteger'},  
   { 'name': 'Second Choice','type': 'esriFieldTypeInteger'},  
   { 'name': 'Third Choice','type': 'esriFieldTypeInteger'},  
   { 'name': 'Fourth Choice','type': 'esriFieldTypeInteger'},  
   { 'name': 'Fifth Choice','type': 'esriFieldTypeInteger'},  
   { 'name': 'Sixth Choice','type': 'esriFieldTypeInteger'}],  
 'geometryType': '',   
 'features': []};  

var index = 0
for (var value in value_counts){
  Dict.features[index] = {
    'attributes': {
      'Quality': value,
      'First Choice': value_counts[value]['First Choice'],
      'Second Choice': value_counts[value]['Second Choice'],
      'Third Choice': value_counts[value]['Third Choice'],
      'Fourth Choice': value_counts[value]['Fourth Choice'],
      'Fifth Choice': value_counts[value]['Fifth Choice'],
      'Sixth Choice': value_counts[value]['Sixth Choice'],
      'Average': value_counts[value]['Average']
    }
  }
  index++;
}

return FeatureSet(Dict);&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="table.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/77332i430F1ED7AB367FB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="table.png" alt="table.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 16:33:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/use-arcade-data-expressions-to-split-ranked-choice/m-p/1315605#M8216</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-04T16:33:35Z</dc:date>
    </item>
  </channel>
</rss>

