Welcome to the LimeSurvey Community Forum

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

Sum 100 as maximum multiple numerical input

  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 3 months ago #232783 by brais24
Please help us help you and fill where relevant:
Your LimeSurvey version: 2.72
Own server or LimeSurvey hosting: Own
Survey theme/template: Default
==================
Hi people, this time i have  a multiple numerical input that i need to check thw SQ001 and SQ002 dont exceed 100, empty or 0 is valid too because is an optional question, the same with SQ003 and SQ004.

I know how to do this with one field putting this on ecuation validation question to check 2 fields separately, but ¿how can i do to check it with te sum os 2 fields? and I need an error message to let klnow the people that the sum of the 2 fields have to be 100 or less.

(is_empty(B10_SQ001) or regexMatch('/^([0-9]|[1-9][0-9]|100)$/',B10_SQ001)) and (is_empty(B10_SQ002) or regexMatch('/^([0-9]|[1-9][0-9]|100)$/',B10_SQ002))

Here an example of my question

 

Thanks for the help.

Please Log in to join the conversation.

  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 3 months ago #232785 by brais24
Replied by brais24 on topic Sum 100 as maximum multiple numerical input
I try to do the same with array text, only numbers, putting this on ecuation validation question but dont work.

(sum(self.sq_COL1.NAOK)<=100) and (sum(self.sq_COL1.NAOK)<=100) and (sum(self.sq_COL1.NAOK)<=100)

The rows of the question have the name FIL1 and FIL2 and the columns have the name COL1 and COL2

I need set 100 as the maximum by column, or, with the multiple numerical input, each 2 fields.

 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago - 2 years 3 months ago #232786 by Joffm
If you code your subquestions as
"YA001", "YA002". "YB003", "YB004"
and set "Min. Value=0 and Max.Value=100
this is sufficient:
sum(self.sq_YA.NAOK)<101 and sum(self.sq_YB.NAOK)<101
 
 


And next time send a lss export of these your relevant questions, please.


And your second question:
What about the subquestion validation equation:
this>=0

and a question validation equation like
sum(self.sq_COL1.NAOK)<101 and sum(self.sq_COL2.NAOK)<101

 

 



Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 3 months ago by Joffm.

Please Log in to join the conversation.

  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 3 months ago #232788 by brais24
Replied by brais24 on topic Sum 100 as maximum multiple numerical input
It work, but i wont be able to make appear the message if you insert more than 100 by year, I try it with this on question validation help.

{if((sum(self.sq_YA)>100 and sum(self.sq_YB)>100),"El total por años debe ser Menor de 100 ","")}<br>

And, if some of the fields are hidden by a previous question, show an error even if you dont answer nothing, I attach images to see that.

Thanks for the help.



 

Please Log in to join the conversation.

  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 3 months ago #232790 by brais24
Replied by brais24 on topic Sum 100 as maximum multiple numerical input
I think it work fine now, I just have to add .NAOK on each self.sq_YA to self.sq_YA.NAOK.


Thanks for the help

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose