Validation of added percentages (not exceeding 100% while cumulating)

Estimada comunidad

Tengo un inconveniente ya que me es necesario crear una validacion en la que el programa sume los porcentajes consignados en los items de la pregunta y si estos no suman 100% arroje una alerta o error diciendo que los porcentajes no suman el 100%?

El problema es que esto viene de una pregunta filtro de respuesta multiple en la que se pregunta los motivos de la perdida de las cosechas, de acuerdo a los motivos seleccionados se despliega para cada items una pregunta del porcentaje de perdida y estos deben sumar el 100% pero cuando hago la validación si no selecciona algún motivo como este campo queda nulo en los porcentajes me esta obligando a colocar así sea un cero.

Espero me puedan ayudar y me supiera explicar.

image

Saludos,

In a select_one question type, enumerators are only able to select one choice per question. Thus when cumulating the total the percentage equals to 100%.

e.g. which fruit do you like?

Respondent 1: Fruit 1
Respondent 2: Fruit 2
Respondent 3: Fruit 1
Respondent 4: Fruit 3
Respondent 5: Fruit 1

Total:

Fruit 1: 3
Fruit 2: 1
Fruit 3: 1

Total respondents (number): 5
% of response with Fruit 1 (3/5x100)=60%
% of response with Fruit 2 (1/5x100)=20%
% of response with Fruit 3 (1/5x100)=20%
So the total respondents (%): 60%+20%+20%=100%



But when it comes with a select_multiple question type, enumerators are able to select more than one choice per question. Thus when cumulating the total, the percentage may exceed 100%.

e.g. let’s have a look with the same example discussed above, which fruit do you like?

Respondent 1: Fruit 1, Fruit 3
Respondent 2: Fruit 2, Fruit 3
Respondent 3: Fruit 1, Fruit 2, Fruit 3
Respondent 4: Fruit 3
Respondent 5: Fruit 1

Total:

Fruit 1: 3
Fruit 2: 2
Fruit 3: 4

Total respondents (number): 5
% of response with Fruit 1 (3/5x100)=60%
% of response with Fruit 2 (2/5x100)=40%
% of response with Fruit 3 (4/5x100)=80%
So the total respondents (%): 60%+40%+80%=180%



However, there is still a way to overcome this drawback with the multiple response if the user wishes to have the % exactly with 100%. The user has to use the response total instead of the total number of respondent.

So following the same example outlined above, which fruit do you like?

Respondent 1: Fruit 1, Fruit 3
Respondent 2: Fruit 2, Fruit 3
Respondent 3: Fruit 1, Fruit 2, Fruit 3
Respondent 4: Fruit 3
Respondent 5: Fruit 1

Total:

Fruit 1: 3
Fruit 2: 2
Fruit 3: 4

Total response: 9
% of response with Fruit 1 (3/9x100)=33.3%
% of response with Fruit 2 (2/9x100)=22.2%
% of response with Fruit 3 (4/9x100)=44.4%
So the total respondents (%): 33.3%+22.2%+44.4%=99.9% (which is 100%)

@Kal_Lam, muchas gracias por la respuesta, sin embargo no he podido implementarla, en el momento de crear una validación con un calculate no me ha permitido realizar dicha validación y me genera problema.

En la anterior imagen muestro como funciona este modulo pero puede que lo este manejando de una manera no correcta.

ejemplo.xlsx (50.0 KB)

Adjunto también el archivo para ver si me puedes dar luces al respecto.

1 Like

Could you kindly explain what you wish to achieve here. Maybe we could have a closer look and see if it’s possible through KoBoToolbox.

We would really appreciate if you could do the following:

  • Share your xlsform in English (so that we could understand your situation much better)
  • Share only a sample (say 1 or 2 questions) so that we could provide you a hint (workaround) on how it can be achieved rather than sharing with us a long list of questions (which would take away our time understanding the same)

Estimado @Kal_Lam

Gracias por la respuesta, estoy adjuntando un modulo a nivel de ejemplo para poder ilustrar un poco lo que estoy necesitando, basicamente en la pregunta c58 se seleccionan una o varias alternativas donde se destina la compra de un producto y a medida que se selecciona se despliega un campo en donde se debe colocar el porcentaje de cada item seleccionado en c58.
Cada item no puede superar el 100% pero la suma de los 6 items tampoco lo pueden hacer.
Hice un calculo en el que me generara una especie de alerta cuando estos no sumen el 100% pero solo me esta apareciendo si seleccionan en c58 todos los 6 items ya que si solo seleccionan algunos no se activa esa alerta, tal vez por lo de los campos nullos que no se interpretan como cero.

Agradeceria si hubiera alguna forma de solucionar o otra vision al respecto.

Ejemplo_validacion.xlsx (12.8 KB)

Hi @LuisB,

You could do the same as outlined in the image below:

In the survey tab of your xlsform:

In the choices tab of your xlsform:

Image 102

Data entry screen as seen in Enketo: (when the percentage exceeds 100)

Data entry screen as seen in Enketo: (when the percentage does not exceed 100)

Reference xlsform:

Cumulative Percentage 100.xlsx (11.6 KB)

1 Like

@kal_Lam muchas gracias por el aporte esta genial y muy funcional para lo que se requiere, un abrazo.

1 Like