How do you clean up unanswered survey questions in a dashboard popup.

172
5
06-05-2020 06:08 AM
Highlighted
New Contributor II

I have a form on Survey123 which collects point data along with other information. This data is put into a webmap which is displayed on a dashboard. When you click on the point in the map the popup shows all possible fields on the form. I would like to clean it up so that only the fields that were answered get displayed. 

Reply
0 Kudos
5 Replies
Highlighted
Esri Contributor

Hi Garrett, this kind of behavior may be possible through the web map via an Arcade expression.

Check out these posts

 https://community.esri.com/community/gis/web-gis/arcgisonline/blog/2017/07/18/conditional-field-disp... 

Can i eliminate empty values using arcade in my pop up? 

There are also some introductory videos for Arcade if you are interested

Pump Up Your Pop-Ups with Arcade Expressions - YouTube 

Getting to Know Arcade - YouTube 

Highlighted
New Contributor II

Thank you!

I will admit I have not written an Arcade Expression before.

I am running into an issue where I have gotten it to leave out null attributes but when there is data it now only lists the data and not the label in the popup. Here is what I am running into. The Numbers Below should say-"Reporters Phone Number"

My expression is:

IIF(isempty($feature["field_9"]),"",$feature["field_9"])

Table to display is:

Any help you can provide is helpful. Thank you

Reply
0 Kudos
Highlighted
Esri Contributor

Try this in your second table row with expression/expr1:

      <td><b> Reporters Phone Number: </b> {expression/expr1}</td>

Reply
0 Kudos
Highlighted
New Contributor II

I thought of that but then it puts it on every popup when the goal is to have it show up only if that point has that field. 

Reply
0 Kudos
Highlighted
New Contributor

Hey Garrett,

Here is some arcade you can use. It will remove any fields that are null/empty. Additionally, the order in which you declare the fields in the script will be how they show up in the popup.

#Create dictionary of fields. Text within single quotes is the desired field alias
var fields = Dictionary('Field Name 1',$feature.Fieldname1,
'Field Name 2',$feature.Fieldname2,
'Field Name 3',$feature.Fieldname3);

#Populate dictionary with fields from above
var fields = [Dictionary('fieldName', 'Field Name 1', 'fieldValue', $feature.Fieldname1), Dictionary('fieldName', 'FieldName2', 'fieldValue', $feature.Fieldname2), Dictionary('fieldName', 'Field Name 3', 'fieldValue', $feature.Fieldname3)];

var popup = '';

#Remove null/empty fields
for(var f in fields){
if (IsNan(fields[f]['fieldValue'])== false && IsEmpty(fields[f]['fieldValue']) == false){

popup += Concatenate([fields[f]['fieldName'], ':', ' ', fields[f]['fieldValue'], '\n'], '');
}
}
return popup;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Just insert the expression into your popup as a custom popup. If there are a ton of fields, it can be tedious but it works!

If its being entered into a Details Element within a dashboard you can also add html tags to line 15 to make text bold or add color. 

Just a note: This does not change the actual data itself in any way. It's just forming the popup in memory and displaying the data in a different way visually.