Select_Multiple Relevant in Survey123: Follow up questions for only answers selected

7548
9
05-18-2018 08:18 AM
KevinBrock2
New Contributor

I am creating a Flow Monitoring Field Maintenance Log for data collected on various pipes. There are several different regions in the pipe a user can select from a list, and from there, depending on which pipe areas they chose, the

corresponding discharge "D" values will appear.

For example, a user can select regions "T1, T3, M1, and B2", doing this will make the corresponding text boxes appear for only those choices. It would look something like this. 

T1_D __________

T3_D __________

M1_D __________

B2_D __________

I have read up on the article "The Art of Hiding, https://community.esri.com/groups/survey123/blog/2016/05/28/the-art-of-hiding , and used every suggestion listed, but nothing seemed to have work. 

I have tried selected(${select_multiple}, '1') OR selected (${select_multiple}, '2') ,(I repeat this step 7 more times)

and I have replace the OR in the previous line with AND, still no progress. The selected option seems to keep the field it is attached to visible at all times on the survey, but I want the "_D" fields to be invisible until selected by the user. 

0 Kudos
9 Replies
IsmaelChivite
Esri Notable Contributor

Hi. Please share your XLS file so we can have a look. Most likely it is a minor syntax problem.

0 Kudos
KevinBrock2
New Contributor

Hi Ismael, 

Attached is my xls file.

Thanks

0 Kudos
LanceCole
MVP Regular Contributor

Try using a single selected(${PIPE_AREA}, '2') for the T2_D text box and see if that works.  If so, repeat for each individually for each text box.  If you need to use multiple conditions it should be selected(${PIPE_AREA}, '1') or selected(${PIPE_AREA}, '2') and selected(${PIPE_AREA}, '3') etc. The "or" can be changed to an "and" depending upon your conditions.  

0 Kudos
DeonLengton
Esri Contributor

Hi Kevin

I think I fixed your issue using the Selected() function. Please have a look.

KevinBrock2
New Contributor

Thanks Lance,

That did the trick, I thought I used that but there must have been an issue with my syntax

cheers

0 Kudos
KevinBrock2
New Contributor

Is it possible to create a select_multiple calculation which would take those specific inputs and average them into a read only field? 

0 Kudos
LanceCole
MVP Regular Contributor

Kevin, 

You should be able to get the sum of all your velocity boxes, whether displayed or not, divided by the count of the multi select.  This assumes the non-displayed values of the velocity boxes are zero or null.  You may want to set the default for the velocity boxes to 0.  The count of a multiselect is count-selected(${select_multi}) replacing "select_multi" with the name of the select_multi on your form.  

KevinBrock2
New Contributor

Using: count-selected(${PIPE_AREA}) div 9 seems to be getting be in the right direction, I am missing the addition of the values somewhere in there though because my output is always .1111 or .22222

0 Kudos
LanceCole
MVP Regular Contributor

The count-selected(${PIPE_AREA}) only provides the number of items selected in your select_mutiple.  For your example above, it would be '3'.  You need to sum all your velocities then divide by the count such as shown below but utilizing your velocity names.  I also included a round statement to clean it up a little.

     round((${velT1} + ${velT2} + … + ${velB3}) div count-selected(${PIPE_AREA}), 2)

I put together a quick example showing this with just three values.  In doing so, I found a bug/issue, the default value of '0' in survey123 only will apply on load.  So, if someone accidently clicks a wrong entry in the select_mutiple then unselects the value it will be set to NaN and the calculation is now broken for the average.  I did find a hack to fix this using a conditional statement in the sum portion of the calculation.  For nine values, the calculation of the average will be long and hopefully will be accepted by survey123.  Please try the following utilizing all nine of your velocity values and the corresponding multi_select value.  I abbreviated PIPE_AREA as PA to keep the sample simple.

   round((if(selected(${PA}), '1'), ${velT1}, 0) + … + if(selected(${PA}), '9'), ${velB3}, 0)) div count-selected(${PA}), 2)

The attached sample shows both the first "broken" calculation and the second revised working equation for the average of just three values. You will note as long as you do not unselect a value once selected everything works.  Please take a look at Formulas—Survey123 for ArcGIS | ArcGIS - "Empty Values" section of the Survey123 documentation which explains the NaN issue in calculations.

0 Kudos