# Calculate the sum for different items within a repeat group question

Dear @Kal_Lam . I am one of the new kobo users and have a bit complex calculation (perhaps not for you) on my table . I have created a loop enabled group .and need to divide the answer of a question (an Integer) by 12 or 1 according to the selection of the answer of another question (Select One) and same goes on in until the loop is not repeated , finally the total should be shown at the end .
Following screen shot may help understand it better . Appreciate your help on this . Thank you so much.

Hi @hussaisa,

Welcome to the community! Would you mind sharing your xlsform (with only these specific questions), and explain your issue a bit so that we are able to dig in if itâ€™s possible.

Have a great day!

Thank you dear .
Unfortunately, I am not allwoed here to upload attachments since I am a new user .
Any other way I can share the xlsform with you .?

I hope the screen shot may help ;
survey

choices

@Kal_Lam

Hi @hussaisa,

Have a great day!

Support_Calculation.xlsx (10.0 KB)

Hi @Kal_Lam Do you need further explanation ?

Hi @hussaisa,

Well so would you explain your requirement in detail now. Would like to see if itâ€™s possible. Please try to be as much detail as possible so that the community understands your requirement in detail.

Have a great day!

1 Like

Dear @Kal_Lam ,

In the above XLSform sheet â€śsurveyâ€ť we want the value of the integer (row number 7) to be divided by the value of select_one xt7ij35 (row number 9) . In case the selection of select_one xt7ij35 is â€śyearâ€ť it divides the integar with 12 and in case the selection of select_one xt7ij35 is â€śmonthlyâ€ť it divides by 1. . Same goes on until the loop is stopped and the final sum should be shown in the note (row number 11)

Hi @hussaisa,

You could do this as outlined in the image below:

In the survey tab of your xlsform:

In the choices tab of your xlsform:

Data entry as seen in Enketo:

Reference xlsform:
Calculations inside a repeat group for specific items.xlsx (12.2 KB)

Have a great day!

2 Likes

Dear @Kal_Lam,

Thank yo so much for your assistance . This is different than what we are expecting , anyways appreciated your time and help.

1 Like

Hi @hussaisa,

You could also try using the `theme-grid` settings to see it in the view that you have shared your screenshot previously. For details, please feel free to have a look at our support article Using Alternative Enketo Web Form Styles.

Have a great day!

1 Like

Dear @Kal_Lam,

Thank you I have already set it as theme-grid . If I may ask you one last thing please.
How to divide or multiply integer or number value please excuse my ignorance

Hi @hussaisa,

Here is an example of how you use the `divide` and `multiply` operations in KoBoToolbox:

As a backup you could also have a look at our support article Advanced Calculate Question Type. This should also be helpful for you.

Have a great day!

1 Like

Dear @Kal_Lam

Can you please have a look at the changes I have made but getting some error. Thank you
.Calculations inside a repeat group for specific items_updated.xlsx (11.8 KB)

1 Like

Hi @hussaisa
Could you also send a screenshot of the errors you are seeing so that I help you figure out the issue.

Stephane

2 Likes

Dear @stephanealoo,

Bundle of thanks for lending the hand . however, I have managed to fix it â€¦ Here is the final version with perfect calculation as desired . Once again appreciate @Kal_Lam for his assistance to give me the push
.Calculations inside a repeat group for specific items_updated.xlsx (11.8 KB)

2 Likes

Hello, I have similar issue with summation inside loop repeat. I can sum the grand total but I cannot sum the "Adult male, adult female â€¦ect