Displaying space delimited string in a repeat group

I have a space delimited string of 3 dates and I want to display each date on a single screen inside a repeat group. I am have create a calculate field with the following calculation but not sure how to get the running index of the repeat group so that I can display each date on it’s screen.

selected-at(${last_3_reported_dates},index)

1 Like

Currently, I don’t know of a reliable way to achieve this. However, with an upcoming* Enketo uplift, you should be able to do it using the same function as above:

type name label calculation
text in space delimited text
begin_repeat repeat Output
calculate val selected-at(${in},position(..) - 1)
note out ${val}
end_repeat

You can try the Enketo uplift branch locally by upgrading to this pre-release:

* Please note that this is not yet supported and should not be used in production. It is planned to be released with CHT 4.0, but there is no guarantee that it will.

5 Likes

+1 to what @binod said! Just want to add that the CHWordle form has some examples of using the position function inside a repeat (but as Binod mentioned, this needs the new Enketo version coming with CHT 4.0).

Also, for that it is worth, I am comfortable guaranteeing that the Enketo uplift will be released with CHT 4.0 :smile:. Development on that branch is complete and testing for it is 99% done. It will be merged soon!

3 Likes