How I can get "repeat values" individually to calculate them separately?

02-13-2020 10:49 PM
New Contributor II


I'm working on smart form of maintenance activities by XLSForm and trying to calculate the weightage of each question to evaluate the priorities of taking action based on the final score of the survey ether it is High or Low.

The engineer want to have weightages in each inspected assets like Transformers, RMU..etc. 

I designed the questions of these assets to be in the "repeat".

It might be two or more transformers inside the substations so the repeat will increase. 

My question is "how I can get repeat values individually to calculate them separately?"

Thanks in advance.

0 Kudos
2 Replies
New Contributor II

Since Indexed-repeat is still not compatible with Survey123 yet, a workaround for this can be by joining the repeat values with a delimiter (,) and then splitting them with Custom JavaScript Function in extension

Step 1: 

join the required repeat values using join in calculation : 


Step 2: 
Create a folder named "extensions" in your form folder and add a js file in it. Add your function to split the string and return the required value: 

function getValFromString(data, idx) {
   return data.split(",")[idx-1]

Step 3:

To calculate index of each item with repeat, use once(count(${cal_total_tx_leaking}))

Step 4:

Call your custom function inside repeat using pulldata 

Hope this helps.

New Contributor II

thanks Tayyab. your wonderful solution solved my question.   

0 Kudos