Calculate the sum of all the values of a question within a roster and use it as a validation condition

I am working with a hh level questionnaire and I am struggling in setting the validation condition for a question within a roster.
The question is “What share of %crop% was dedicated to %a specific use% during %refperiod%?”. I want to make sure that the share of crop dedicated to different uses sum up to 100 maximum.
The question that starts this roster is a multiselect question with the list of possible crop uses. Then, the question regarding the share of crop dedicated to each selected use is within the roster.
In other words, if the respondent says that he uses potatoes for home consumption, selling and animal feed, I want to make sure that when specifying the shares of potatoes corresponding to each activity, their sum does not exceed 100.
Thank you in advance for your support!

Hello @MartinaF ,

just use the Sum() function.

See the “Burgers” section in the “Public example User
questions and common patterns” questionnaire for an example of use.

Please make sure you have undergone some training regarding the Survey Solutions questionnaire design.

Best, Sergiy

Dear @sergiy,
Sorry but I cannot find the example that you have indicated, can you send me the link?

Hello @sergiy,

I encountered a similar issue. In the Burger example, there is only one question in the roster, which prevents me from utilizing the ‘sum’ function as presented. The error message indicates that the ‘RosterCollection’ lacks a definition for ‘sum’.

In my agricultural survey (uploaded as Era1), I inquire about the overall size of the land (total_land). Subsequently, within a roster for various plots, I inquire about the size of each individual plot (plot_size). My objective is to validate that the cumulative size of the plots does not exceed the total_land. Due to the roster’s continuation with additional questions, I have not been able to replicate the same approach as demonstrated in the example.

Is there a workaround for addressing this situation?

Thank you and best regards,

Hello @omershlomi ,

  1. I have checked the questionnaire Era1 uploaded to the public demo server:$1
    but it doesn’t contain the questions with variable names as mentioned in your post.

  2. I don’t see how presence of additional questions affects the calculation of the total. Correspondingly I believe the burgers example should still apply.

  3. If anything, I’d follow the lead that Survey Solutions advises:

The error message indicates that the ‘RosterCollection’ lacks a definition for ‘sum’.

Perhaps it is just a matter of writing Sum() instead of sum() ??

Best, Sergiy

Thank you @sergiy , I’ve managed to do it through the Burgers example again and it worked.