Modifying label text per repeat?

Hi all!

Practicing a little with XLS Form and wondering what the best way to achieve this would be. I have a repeating question asking the user how many pets they have. How would I modify the text in the label for each repeat to say 'What type of animal is your first pet?', 'What type of animal is your second pet?'... etc

At the moment I just have set responses as shown below which read quite flatly.

Appreciate any advice!

1 Like

I have done something very similar where i have repeating photos and I want different views for the first, second etc images and adjust the label to indicate this.

With a calculate that has a nested if, you can use position(..) to create your label eg
if(position(..) = 1, 'What type of animal is your first pet?', if(position(..) = 2, 'What type of animal is your second pet?, '')
but you don't want to have to nest these up to n pets unless you have a reasonable repeat count limit.

You could reword such that your calculate is only position(..) to return the integer as a text string and the label is then something like 'What type of animal is pet #${calculatedposition}?'

3 Likes

Thank you, that's brilliant. You've helped me understand how position functions and I've got it working as suggested :smiley:

2 Likes