Error with calculation command

1. What is the issue? Please be detailed.
I created a form for my questionnaire using XLS. I included a calculation command to calculate participants' score as soon as the last question is answered. When I tried to validate the form on ODK (https://getodk.org/xlsform/), it gave me the error message below:

Error: ODK Validate Errors:

Something broke the parser. See above for a hint.
Error evaluating field 'totalCapacityScore' (${totalCapacityScore}[1]): The problem was located in Calculate expression for ${totalCapacityScore}
XPath evaluation: type mismatch
This field is repeated:

${repeatConsentCapacity}[1]/researchPurpose[1];${repeatConsentCapacity}[2]/researchPurpose[1]

You may need to use the indexed-repeat() function to specify which value you want.
Caused by: org.javarosa.xpath.XPathTypeMismatchException: The problem was located in Calculate expression for ${totalCapacityScore}
XPath evaluation: type mismatch
This field is repeated:

${repeatConsentCapacity}[1]/researchPurpose[1];${repeatConsentCapacity}[2]/researchPurpose[1]

You may need to use the indexed-repeat() function to specify which value you want.
... 11 more

The following files failed validation:
${V1_26082023_Capacity} to Consent.xml

Result: Invalid

2. What steps can we take to reproduce this issue?
I am not sure what you mean here.

3. What have you tried to fix the issue?
I have tried to edit the field with the error and compared it with similar forms I had done

4. Upload any forms or screenshots you can share publicly below.

Hi @Afolayan
When you get a chance, please introduce yourself here. I'd also encourage you to add a real picture as your avatar because it helps build community!

You are trying to refer to a question that is in a repeat group. To do that you have to use the indexed-repeat() function to specify which value you want (from which group) as the error message says.
You can read about that function in our docs https://docs.getodk.org/form-repeats/#referencing-repeated-questions-from-outside-the-repeat and also find many sample forms on this forum (just use the search icon and enter indexed-repeat).