Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Question Validation based on Total of Row

  • saifshaikh
  • saifshaikh's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 years 1 month ago #213407 by saifshaikh
Question Validation based on Total of Row was created by saifshaikh
I need to validate a Array text question based on Total of row should be 100. Array Text subquestion is piped using Array filter from previous question.

I tried using - (sum(self.sq_a.NAOK)==100) and (sum(self.sq_b.NAOK)==100) and (sum(self.sq_c.NAOK)==100) and (sum(self.sq_d.NAOK)==100), but it does not validate for filter rows, but for all rows.

attached is the survey

Thanks in advance!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #213413 by Joffm
Replied by Joffm on topic Question Validation based on Total of Row
Hi,
so what exactly is your question?

1. Your array filter doesn't work; you should use subquestion relevance to show only rows that are not rated "can't say".

2. The validation is absolutely fine.
Of course it displays ALL cells with a red border if there is an error somewhere; it is question validation.
And you may fine tune your validation tip like

{if(sum(self.sq_a.NAOK)!=100,"Sum of Row A is currently "+sum(self.sq_a.NAOK)+", but should be 100",if(sum(self.sq_b.NAOK)!=100,"Sum of Row B is currently "+sum(self.sq_b.NAOK)+", but should be 100",if(sum(self.sq_c.NAOK)!=100,"Sum of Row C is currently "+sum(self.sq_c.NAOK)+", but should be 100",if(sum(self.sq_d.NAOK)!=100,"Sum of Row D is currently "+sum(self.sq_d.NAOK)+", but should be 100","Everything is fine"))))}


And you get this
   

 



 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • saifshaikh
  • saifshaikh's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 years 1 month ago #213418 by saifshaikh
Replied by saifshaikh on topic Question Validation based on Total of Row
Thanks Joffm for the quick reply.

the issue is i need the sum only for the filter option. it only works if each of all four option rows sum is 100. the array filter works fine.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #213434 by Joffm
Replied by Joffm on topic Question Validation based on Total of Row
Hi,
well, concerning the array filter.
That was on my side. My settings are not to show "no answer" in not mandatory questions.

Validation.
So you have to add this condition to the validation equation
Something like
{(sum(Q21.sq_a.NAOK)==100 or Q20_a=='no answer') and (sum(Q21.sq_b.NAOK)==100 or Q20_b=='no answer') ...
Here I'd set the question to mandatory with my own code for "no answer"

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: saifshaikh
The topic has been locked.
  • saifshaikh
  • saifshaikh's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 years 1 month ago #213623 by saifshaikh
Replied by saifshaikh on topic Question Validation based on Total of Row
Thanks Joffm, unfortunately it did not worked out as per what I was expecting.

Alternatively what I did was split it into 4 different questions.

Saif
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #213627 by Joffm
Replied by Joffm on topic Question Validation based on Total of Row

unfortunately it did not worked

is always very unspecific.

You have to show what you tried. Otherwise no help possible.

But you have an satisfying solution .

Joffm


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose