Increment fish scale number and card

293
2
Jump to solution
04-05-2022 01:19 AM
DavidHines
New Contributor II

We collect scale samples from fish and place one scale from each fish on a card with 20 boxes (one scale per box).  Each day the card starts with number 1, after it has 20 scales a new card is started and is number 2 etc..  Each scale starts with number 1 until there is 20 then it starts over and the card increases by one.

How can I replicate this functionality in Survey123?  Can I do it with formulas and calculations or do I need JS script?

Any help is greatly appreciated, Thank you.

This is the code in VBA for Access:

If intScale = 20 Then
  Me!Card = intCard + 1
  Me!Scale = 1
Else
  Me!Scale = intScale + 1
  Me!Card = intCard
End If

This is the page of the survey that I need to do the calculation:

begin groupPage2BioDetail
begin repeatPage2_BioDetailBioDetail
textCardCard
textscale_1Scale
select_one SexsexSex
select_one MarkMarkMark
textlength_1Fork Length
textCWT_IDCWT ID
end repeat  
end group  
0 Kudos
1 Solution

Accepted Solutions
AndyMcClary
New Contributor III

Hi David,

To elaborate on Doug's comment on using position I think this should get you what you're looking for:

for the card:  int((position(..)-1) div 20)+1 

and for the scale: if( position(..) mod 20= 0, 20, position(..) mod 20)

View solution in original post

2 Replies
DougBrowning
MVP Esteemed Contributor

You can now use position(..) and it will give you the repeat number.  One way was to use once(count(somefield)).

Hope that helps

AndyMcClary
New Contributor III

Hi David,

To elaborate on Doug's comment on using position I think this should get you what you're looking for:

for the card:  int((position(..)-1) div 20)+1 

and for the scale: if( position(..) mod 20= 0, 20, position(..) mod 20)