Welcome to the LimeSurvey Community Forum

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

Show error message when minor than

  • brais24
  • brais24's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
11 months 1 week ago #265266 by brais24
Show error message when minor than was created by brais24
Please help us help you and fill where relevant:
LimeSurvey version: Versión 5.6.49+231212
Own server or LimeSurvey Cloud: Own
Survey theme/template: Fruity
==================
hi there, i want to do a simple thing that i think it was easy to do, at first, i have to show an error message if TP1 is not equal to the surrounded in yellow TP2 cells (i attach lss) , and it works putting this on equation validation question

(sum(TP1.NAOK) == sum(TP2_SQ001_SQ001,TP2_SQ001_SQ002,TP2_SQ002_SQ001,TP2_SQ002_SQ002,TP2_SQ003_SQ001,TP2_SQ003_SQ002,TP2_SQ004_SQ001,TP2_SQ004_SQ002)

And this on question help

{if((sum(TP1.NAOK) == sum(TP2_SQ001_SQ001,TP2_SQ001_SQ002,TP2_SQ002_SQ001,TP2_SQ002_SQ002,TP2_SQ003_SQ001,TP2_SQ003_SQ002,TP2_SQ004_SQ001,TP2_SQ004_SQ002)), '', 'Os datos non coinciden co total de TP1.<br />')}

Works fine, when its equal, dont show the message, and when its different, show the error message.

But the problem comes when they say to me that the error have to shown just in case TP1 is greater than the sum of the other cells, i think just changing == for <= is enough but when i do that, starts to have a weir behavior, if you put 5 and 5 on the 2 first cells on TP2 and put 10 on TP1 dont show the message, but if you put 9,8,7 or 11,12 or 13 on TP1, show the error message.

Can anyone tell me what im doing wrong?

Thanks for the help.

File Attachment:

File Name: limesurvey...8132.lss
File Size:33 KB


Image to understand the example
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 months 1 week ago - 11 months 1 week ago #265270 by Joffm
Replied by Joffm on topic Show error message when minor than
Hi,
I wonder why you use this
sum(TP1)? This is only one value, what do you sum?

Then I recoded the x-axis to "X001", "X002" makes the first equation a little bit shorter (you can use the self-variable.
So with a validation equation of
TP1.NAOK >=  sum(self.sq_X001.NAOK,self.sq_X002.NAOK) and sum(TP2_SQ001_X001,TP2_SQ001_X002) == sum(TP2_SQ001_X003,TP2_SQ001_X004,TP2_SQ001_X005) AND sum(TP2_SQ002_X001,TP2_SQ002_X002) == sum(TP2_SQ002_X003,TP2_SQ002_X004,TP2_SQ002_X005) AND sum(TP2_SQ003_X001,TP2_SQ003_X002) == sum(TP2_SQ003_X003,TP2_SQ003_X004,TP2_SQ003_X005) AND sum(TP2_SQ004_X001,TP2_SQ004_X002) == sum(TP2_SQ004_X003,TP2_SQ004_X004,TP2_SQ004_X005)

and a validation tip of
{if(TP1.NAOK < sum(self.sq_X001.NAOK,self.sq_X002.NAOK),'TP1 smaller than the sum',if(sum(TP2_SQ001_X001,TP2_SQ001_X002) != sum(TP2_SQ001_X003,TP2_SQ001_X004,TP2_SQ001_X005),'error in row 1', if(sum(TP2_SQ002_X001,TP2_SQ002_X002) != sum(TP2_SQ002_X003,TP2_SQ002_X004,TP2_SQ002_X005),'error in row 2',if(sum(TP2_SQ003_X001,TP2_SQ003_X002) != sum(TP2_SQ003_X003,TP2_SQ003_X004,TP2_SQ003_X005),'error in row 3',if(sum(TP2_SQ004_X001,TP2_SQ004_X002) != sum(TP2_SQ004_X003,TP2_SQ004_X004,TP2_SQ004_X005),'error in row 4','')))))}

I see this (TP1 was 22)

 
 

Of course you get the initial error. 
At the start the sum of the array is always less than TP1
To avoid this you have to add the test of "is_empty".

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 11 months 1 week ago by Joffm.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose