Select to view content in your preferred language

Strange behavior with repeat question aggregation (Sum / Count) and with repeat_count setting.

1504
4
Jump to solution
07-19-2021 05:24 AM
Moataz_M_Kilany
Emerging Contributor

Greetings,

I'm facing a problem with a repeat question aggregation and hoping that I can get some help.

The problem is described here as well as in attached word document for more organization:

I made a survey that submits to a custom feature service (SQL server - based) , I have simplified it to only show questions relevant to the problem in question.

The survey collects traffic signal settings within an intersection using four select multiple questions. Each question selects the phase sequence for signal red balls, red arrows , green balls and green arrows. For example, if first phase is a red ball, the P1 check box will be selected at green ball question.

The survey next performs some string operations on the select_multiple questions. It mainly checks if the resultant string contains phase1, phase2, phase3... etc. These checks are done in hidden questions p1 through P4 on xls form (See Attached). Results are summed within the last two questions HeadTotalGreen and ArrowTotalGreen.

Now, on the web app interface, the first repeat selections produce correct results in result box. The problem happens when I add a new repeat:

  • Both repeats calculations are reset to zero.
  • when the second repeat selections are set, whatever the result is, it gets posted to the first repeat’s results box instead of the second !!!   

 

Here is a test case

1: Set the first repeat with result : 2 , 1

Moataz_M_Kilany_4-1626697079888.png

 

 

 

2: Set second repeat with result : 3, 2

Moataz_M_Kilany_5-1626697079892.png

 

 

 

 

 

 

 

 

 

3: Check first repeat again: result is incorrectly changed to 3, 2 (as second repeat's result)

Moataz_M_Kilany_6-1626697079893.png

 

It seems that the first repeat takes question values from the last repeat some how !!.

 

Here's the custom feature service signature:

 

  • OBJECTID ( type: esriFieldTypeOID, alias: ObjectID, editable: false, nullable: false, defaultValue: null, modelName: OBJECTID )
  • globalid ( type: esriFieldTypeGlobalID, alias: GlobalID, editable: false, nullable: false, length: 38, defaultValue: null, modelName: globalid )
  • HeadFlashRedWays ( type: esriFieldTypeSmallInteger, alias: Head Flash Red Ways, editable: true, nullable: true, defaultValue: null, modelName: head_fl_red_ways )
  • HeadFlashYellowWays ( type: esriFieldTypeSmallInteger, alias: Head Flash Yellow Ways, editable: true, nullable: true, defaultValue: null, modelName: head_fl_yellow_ways )
  • HeadTotalGreen ( type: esriFieldTypeSmallInteger, alias: Head Total Green, editable: true, nullable: true, defaultValue: null, modelName: head_totalgreen )
  • ArrowTotalGreen ( type: esriFieldTypeSmallInteger, alias: Arrow Total Green, editable: true, nullable: true, defaultValue: null, modelName: arrow_totalgreen )
  • CRepArrowCountHead ( type: esriFieldTypeSmallInteger, alias: Rep Arrow Count Head, editable: true, nullable: true, defaultValue: null, modelName: c_rep_arrowcount_head )
  • parentrowid ( type: esriFieldTypeGUID, alias: Parent Row ID, editable: true, nullable: true, length: 38, defaultValue: null, modelName: parentrowid )
  • created_user ( type: esriFieldTypeString, alias: created_user, editable: false, nullable: true, length: 255, defaultValue: null, modelName: created_user )
  • created_date ( type: esriFieldTypeDate, alias: created_date, editable: false, nullable: true, length: 8, defaultValue: null, modelName: created_date )
  • last_edited_user ( type: esriFieldTypeString, alias: last_edited_user, editable: false, nullable: true, length: 255, defaultValue: null, modelName: last_edited_user )
  • last_edited_date ( type: esriFieldTypeDate, alias: last_edited_date, editable: false, nullable: true, length: 8, defaultValue: null, modelName: last_edited_date )
  • HeadQuantity ( type: esriFieldTypeSmallInteger, alias: Head Quantity, editable: true, nullable: true, defaultValue: null, modelName: quantity )

 

=========

The second problem, I'm trying to use HeadGroupCount question to set repeat_count dynamically. whenever I put ${HeadGroupCount} in the repeat’s repeat_count column, trying to fix repeat counts to a value, it gives me an error message telling that the survey is not compatible with feature service and that there is a field that does not exist up there “missing field: 1”.

 

Thank you for your patience.

Let me know if I can make any clarifications.

 Thank you.

 

 

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Ok that makes more sense.  

First remove the relevant from the p1_green field - using a relevant on a calc can get funky.

Then I would use contains vs selected at since they could check the boxes in any order.

p1_green changes to 

if((contains(${green_arrow_phases}, "P1") or contains(${green_ball_phases}, "P1")) and not(contains(${red_ball_phases}, "P1")), 1, 0)

Works for me.

P1.gif

Then just so that for all your pX_green fields.

Hope that is it.

View solution in original post

0 Kudos
4 Replies
DougBrowning
MVP Esteemed Contributor

If I am seeing it right it seems that you could just use count-selected(${green_arrow_phases}) instead since you just want to know how many checkboxes are marked.  Way easier.

For the second issue the service needs to have a field called repeat_count in there.  See here  https://community.esri.com/t5/arcgis-survey123-questions/delete-hide-repeat-count-fields-on-feature-...

Hope that helps

 

0 Kudos
Moataz_M_Kilany
Emerging Contributor

Doug, thank you for going through my long post.

I'll try add the _count field to parent layer, as explained in the post you pointed to, this might as well solve the first problem.

yes it would be way easier to use count-selected. However, I can't just count selections, I need to know which phases are selected (P1,.. P4) at each questions. The goal is to count the number of green signals and green arrow. A green signal is counted if there is green ball or a green arrow without red ball at the same phase.

In the Image below, there is only one green signal because only P1 (phase 1) satisfies the condition.

Moataz_M_Kilany_0-1626712228679.png

The rest of survey calculations uses similar checks with different conditions.

 

Thank you.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Ok that makes more sense.  

First remove the relevant from the p1_green field - using a relevant on a calc can get funky.

Then I would use contains vs selected at since they could check the boxes in any order.

p1_green changes to 

if((contains(${green_arrow_phases}, "P1") or contains(${green_ball_phases}, "P1")) and not(contains(${red_ball_phases}, "P1")), 1, 0)

Works for me.

P1.gif

Then just so that for all your pX_green fields.

Hope that is it.

0 Kudos
Moataz_M_Kilany
Emerging Contributor

Hi, 

When I replaced selected-at() with contains() and did the proper modifications, the problem persisted (adding new repeats after the first miss up calculations in the first one - on web interface only). However I could use your advice to solve the problem as follows.

 

1- Removed relevance conditions from some calculated fields which results are based off of.

2- Changed the P1- P20 calculated fields types from "calculated" to "text" with appearance  = "hidden".

Those two modifications did it and when I change any back, the problem comes back !!.

 

Attached the last modified document, 

Thank you, appreciate your help.