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 group | Page2 | BioDetail |
begin repeat | Page2_BioDetail | BioDetail |
text | Card | Card |
text | scale_1 | Scale |
select_one Sex | sex | Sex |
select_one Mark | Mark | Mark |
text | length_1 | Fork Length |
text | CWT_ID | CWT ID |
end repeat | ||
end group |
Solved! Go to Solution.
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)
You can now use position(..) and it will give you the repeat number. One way was to use once(count(somefield)).
Hope that helps
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)