Using Survey123 select_multiple questions in Ops Dashboard?

3094
7
Jump to solution
05-22-2019 07:00 AM
Danielle_Papineau
Occasional Contributor II

I'm looking for any suggestions or solutions to using a Survey123 select_multiple response within Operations Dashboard.  This question type outputs as a comma delimited field which makes it pretty much unusable in Ops Dashboard.  

I went through the steps of pulling out the unique answers into hidden fields as yes/no... through the calculation column:  if(selected(${name},'somevalue'), 'Yes', 'No')  ...but still can't find a good solution to displaying/summarizing this info in any of the Dashboard elements.

What I would like to be able to do to count the number of times a value (not a response) has been selected for each question and also graph those with the other.  This works well in the survey123.arcgis.com website, but Ops Dashboard is completely different...

Thanks!

1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi Danielle,

Hi Eric,

 

This issue has been raised to technical support before, and this is the public explanation:

 

"Selections made for a select_multiple question are stored as a comma-separated string. This is a known limitation of select_multiple questions.

 

In order to query the selections individually, each selection can be separated out to its own question. This can be achieved using if() statements with the selected(question, value) function. These additional questions can be hidden if necessary.

 

This technique is described in the following GeoNet blog (refer to the "Controlling how user selections are stored in ArcGIS" section):

https://community.esri.com/groups/survey123/blog/2017/08/30/understanding-multiple-choice-questions-...

 

Additional information on these functions is available in this blog post:

https://community.esri.com/groups/survey123/blog/2018/12/02/survey123-tricks-of-the-trade-xlsform-fu...

 

 

I hope this is helpful on the Survey123 form side of things. Additionally, there is a new enhancement logged for a change in Operations Dashboard: ENH-000129890 - "Allow for the indicator widget in ArcGIS Dashboard to parse through a string field that was created by a 'select_multiple answers' question in Survey 123, so that the widget accurately counts the number of times each answer occurs." While it has not yet been decided whether or not this enhancement will be implemented, you can always call in to Technical Support and ask that it be attached to your account.

 

Thank you,

Gillian

View solution in original post

7 Replies
DougBrowning
MVP Esteemed Contributor

This is what I do in the form.

Have a calc field that counts only non 0 answers answers if(${HeightHerbaceous}>0,1,0)

Then I have a second field to do an avg using Sum.  sum(${HeightHerbaceous}) div sum(${nonzeroherbhgt})

You can also use things like count() to see how many total.

You could do this then you will have a field in your form that already has the Avg for you.  Then you can use this field directly in Ops Dashboard.

In your example of 

if(selected(${name},'somevalue'), 'Yes', 'No')

Change to 

if(selected(${name},'somevalue'), 1, 0)

Of course if someone edits the data directly later the calcs will be wrong.

Danielle_Papineau
Occasional Contributor II

Thanks Doug! 

I'm not sure this will do what I need, but will keep this in mind for next time and give it a try...

After I added the if(selected(${name},'somevalue'), 'Yes', 'No') calculation, I wasn't able to republish my survey, presumably because that would have created too many fields.  I'm not sure what the field limit is, but I'm pretty sure I hit hit.  I removed these (actually just made them "null" under the field type column so they wouldn't write), and was able to republish the survey.  They were functioning fine before trying to republish, so I'm pretty certain there wasn't an error in the equation.

In regards to your suggestion, if I'm thinking through this correctly, I could use the Indicator element for a single "somevalue", but not the Serial Chart to graph all answers from a single question. Do you know if it's possible to force multiple attributes into the Serial Chart in order to build a graph from the specific fields I need (instead of it being built from a single attribute)?  Not sure if that makes sense.

Danielle

0 Kudos
DougBrowning
MVP Esteemed Contributor

So you mean you want to point to a string field and have it pie chart the options right?  I have never found a way to do this.  Seems simple enough but Arc seems to assume no strings, which is weird really - seems like the best use of this.

0 Kudos
by Anonymous User
Not applicable

Hi Danielle,

Hi Eric,

 

This issue has been raised to technical support before, and this is the public explanation:

 

"Selections made for a select_multiple question are stored as a comma-separated string. This is a known limitation of select_multiple questions.

 

In order to query the selections individually, each selection can be separated out to its own question. This can be achieved using if() statements with the selected(question, value) function. These additional questions can be hidden if necessary.

 

This technique is described in the following GeoNet blog (refer to the "Controlling how user selections are stored in ArcGIS" section):

https://community.esri.com/groups/survey123/blog/2017/08/30/understanding-multiple-choice-questions-...

 

Additional information on these functions is available in this blog post:

https://community.esri.com/groups/survey123/blog/2018/12/02/survey123-tricks-of-the-trade-xlsform-fu...

 

 

I hope this is helpful on the Survey123 form side of things. Additionally, there is a new enhancement logged for a change in Operations Dashboard: ENH-000129890 - "Allow for the indicator widget in ArcGIS Dashboard to parse through a string field that was created by a 'select_multiple answers' question in Survey 123, so that the widget accurately counts the number of times each answer occurs." While it has not yet been decided whether or not this enhancement will be implemented, you can always call in to Technical Support and ask that it be attached to your account.

 

Thank you,

Gillian

Teresa_Blader
Occasional Contributor III

I was able to create something that works really well after combining a few community posts if anyone comes across this in the future. This counts the number of times a multiple choice option was selected, and also renames the label to match what it was labeled as in Survey123. 

Notes:

  • This uses the Grouped Value option in Dashboard where the Category is set to the 'split_choices' field from the 'new' featureSet, then the Statistic is set to 'Sum' the 'split_count' field.
  • The main step to get the relabeling to work is wrapping the "Trim" function in the 'decode_dict' to translate the values
  • Be sure to add the decoded values as Categories in the dashboard Series tab, not the original labels. 

 

// Reference layer using the FeatureSetByPortalItem() method. 
var portal = Portal('https://www.arcgis.com') 
var fs = FeatureSetByPortalItem( 
    portal, 
    '<ID#>', 
    0, 
    ['<fieldnames>'], 
    false 
); 

// Create empty array for features and feat object 
var features = []; 
var feat; 
//give the codes a new label to match what was entered in the survey
var decode_dict = { 
  "Local":"Born Here", 
  "Indigenous":"Native, Indigenous, or Aboriginal", 
  "Conflict":"Fleeing War, Tension, Persecution, Poverty; Seeking Refuge", 
  "Forced":"Slavery, Human Trafficking, Criminal Relocation", 
  "Career":"Opportunity - Employment or Education", 
  "Family":"Adoption, Marriage, or Reunification", 
  "Health":"Medical, Health, Environment, or Wellness", 
  "Colonization":"Colonization" 
} 

// Split comma separated types and store in dictionary.   
for (var feature in fs) {  
    var split_array  =  Split(feature["<fieldname>"], ',')  
    var count_arr = Count(split_array)  
    for(var i = 0; i < count_arr; i++ ){  
        feat = { 
            'attributes': { 
                'split_choices': decode_dict[Trim(split_array[i])] 
            } 
        } 
        Push(features, feat); 
}} 

// Empty dictionary to capture each hazard reported as separate rows.  
var choicesDict = { 
    'fields': [ 
        { 'name': 'split_choices', 'type': 'esriFieldTypeString'}],  
    'geometryType': '', 
    'features': features 
};  

// Convert dictionary to featureSet.  
var fs_dict = FeatureSet(choicesDict); 

// Return featureset after grouping by hazard types.  
return GroupBy(fs_dict, ['split_choices'],  
       [{ name: 'split_count', expression: 'split_choices', statistic: 'COUNT' }]);  

 

Teresa Blader
Olmsted County GIS Specialist
Bec
by
New Contributor III

Teresa,

 

I was trying out your provided code to do something similar with a multiple choice selection for a field called, material, within my AGO dashboard.  I'm running into an issue where when I test the code, I get the following error message:  Execution error - Key not found - yardwaste. Verify test data.  I checked my dictionary names against the material list in my survey and they match exactly what I have within my survey.  I'm not sure what could be causing this issue.  Any help would be greatly appreciated!

var portal = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(
    portal,
    '7ee1e75e40904b28bc1b9710f7824cad',
    0,
    ['material'],
    false
);

var features = [];
var feat;
var decode_dict = {
    "Bicycles": "bicycles",
    "Bulk Waste": "bulkwaste",
    "Clothing": "clothing",
    "Electronics": "electronics",
    "Food Scraps": "foodscraps",
    "Furniture": "furniture",
    "Household Acceptable Waste": "housewaste",
    "Recycling": "recycling",
    "Scrap Metal": "scrapmetal",
    "Styrofoam": "styrofoam",
    "Yard Waste": "yardwaste"
};

for (var feature in fs) {
    var split_array = Split(feature["material"], ',');
    var count_arr = Count(split_array);

    for (var i = 0; i < count_arr; i++) {
        feat = {
            'attributes': {
                'split_choices': decode_dict[Trim(split_array[i])]
            }
        };
        Push(features, feat);
    }
}

var choicesDict = {
    'fields': [
        { 'name': 'split_choices', 'type': 'esriFieldTypeString'}
    ],
    'geometryType': '',
    'features': features
};

var fs_dict = FeatureSet(choicesDict);

return GroupBy(fs_dict, ['split_choices'],
    [{ name: 'split_count', expression: 'split_choices', statistic: 'COUNT' }]);

 

0 Kudos
Bec
by
New Contributor III

I finally figured out what was causing the issue in my data expression.  I had my decode dictionary values backwards.  I reversed those and now the code works as expected!  I included a picture of my output when I tested the data expression.

 

var portal = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(
    portal,
    '7ee1e75e40904b28bc1b9710f7824cad',
    0,
    ['material'],
    false
);

var features = [];
var feat;
var decode_dict = {
    "bicycles": "Bicycles",
    "bulkwaste": "Bulk Waste",
    "clothing": "Clothing",
    "electronics": "Electronics",
    "foodscraps": "Food Scraps",
    "furniture": "Furniture",
    "housewaste": "Household Acceptable Waste",
    "recycling": "Recycling",
    "scrapmetal": "Scrap Metal",
    "styrofoam": "Styrofoam",
    "yardwaste": "Yard Waste"
};

for (var feature in fs) {
    var split_array = Split(feature["material"], ',');
    var count_arr = Count(split_array);

    for (var i = 0; i < count_arr; i++) {
        var currentMaterial = Trim(split_array[i]);
        Console("Processing value: " + currentMaterial);

        feat = {
            'attributes': {
                'split_choices': decode_dict[currentMaterial]
            }
        };
        Push(features, feat);
    }
}

var choicesDict = {
    'fields': [
        { 'name': 'split_choices', 'type': 'esriFieldTypeString'}
    ],
    'geometryType': '',
    'features': features
};

var fs_dict = FeatureSet(choicesDict);

return GroupBy(fs_dict, ['split_choices'],
    [{ name: 'split_count', expression: 'split_choices', statistic: 'COUNT' }]);

 

Data Expression Output.PNG