Select to view content in your preferred language

Issue with max and repeat position/index

727
1
Jump to solution
01-04-2024 03:28 PM
DouglasKnabe
Occasional Contributor

I have an odd issue. I have a set of repeating questions (species and count). I calculate a string as "count - species", which I then join to create a list of all entries for users to see. I also created an Index within the repeat (repIndex) using position(..), which I then use to pull the "count-species" for the last 5 entries using indexed-repeat (${count-species}, maxIndex), indexed-repeat(${count-species}, maxIndex-1) and so on. maxIndex is calculated outside of the repeat as max(${RepIndex}).

This works fine until I hit 10 entries. At this time, the method of taking the maxIndex fails and will not go past 9; this max is displayed as Max Repeat Index. The repIndex variable (displayed as Repeat Index) is still working fine. taking the max of the counts works fine (Max Count), but taking the max of the repIndex fails after I pass 9 entries. Any insight?

I've attached a screenshot of the survey and the xlsForm

Any insight as to why max() falls apart for the index

 

0 Kudos
1 Solution

Accepted Solutions
DouglasKnabe
Occasional Contributor

Found the solution. I'm pretty new to Survey123, so that probably explains it BUT...

Found out when using a Calculate field, it doesn't necessarily get stored as the expected data type, and if using what you believe to be an integer, you must specify in the Bind::type field. Taking the max (which also wasn't specified as int) of the field that was a calculate field (position(..)), wasn't working properly due to this. Taking the max of the entered counts worked fine because the count was coded as an integer and was not a Calculate field.

View solution in original post

0 Kudos
1 Reply
DouglasKnabe
Occasional Contributor

Found the solution. I'm pretty new to Survey123, so that probably explains it BUT...

Found out when using a Calculate field, it doesn't necessarily get stored as the expected data type, and if using what you believe to be an integer, you must specify in the Bind::type field. Taking the max (which also wasn't specified as int) of the field that was a calculate field (position(..)), wasn't working properly due to this. Taking the max of the entered counts worked fine because the count was coded as an integer and was not a Calculate field.

0 Kudos