Welcome to the LimeSurvey Community Forum

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

several nested if statements

  • suselko
  • suselko's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 10 months ago #201406 by suselko
several nested if statements was created by suselko
I cannot pin down the reason why the attached question is not working. It

File Attachment:

File Name: limesurvey..._585.lsq
File Size:3 KB

File Attachment:

File Name: limesurvey..._585.lsq
File Size:3 KB

File Attachment:

File Name: limesurvey..._585.lsq
File Size:3 KB
works fine when there are just a few if statements but not when there are 43 of them. Is there a maximum number of if statements in an equation? Thanks for help
The topic has been locked.
  • suselko
  • suselko's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 10 months ago #201407 by suselko
Replied by suselko on topic several nested if statements
Just to clarify, LS recognizes it as plain text, not a conditional statement with variables in it.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #201410 by Joffm
Replied by Joffm on topic several nested if statements
Obviously there is a limit of nesting.
I tried by removing one by one till it worked.

But you may use a workaround.

Do a different kind of nesting.
First sort the cities by number.
Then you can say:
if(Code<75,new if-statement of cities with numbers below75,new if-statement of cities with numbers above75)


{if(fbcode<75,
if(fbcode==44,"Airdrie",if(fbcode==55,"Andover",if(fbcode==56,"Arnold",if(fbcode==57,"Barrow",... ,if(fbcode==72,'Isle_of_Wight',"")))))))))))))))))))))),
if(fbcode==75,'Leeds_North_and_West',if(fbcode==76,'Letchworth',if(fbcode==77,'Lincoln',if(fbcode==78,'North_Enfield',if(fbcode==79,'North_Lakes',if(fbcode==82,'Northern_Devon',...,if(fbcode==99,'worcester','')))))))))))))))))))
)}

This way the nesting is lowered.


Joffm

And please, only attach lss exports.

lsq and lsg exports are language sensitive.
You cannot import a question into a survey with different base languages.

So first we have to guess which base language you used, and
second we have to create a new survey with this base language to import your question export.
So ease our life.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • suselko
  • suselko's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 10 months ago #201417 by suselko
Replied by suselko on topic several nested if statements
Many thanks Joffm. Your solution works, but I have actually pinned it down - one of the names had an apostrophe in it, which was confusing the code, because I used 'name' instead of "name". So 43 if statements is not too many after all. Sorry to waste your time!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #201420 by Joffm
Replied by Joffm on topic several nested if statements
Hi,

yes, 'King's_Lynn'.
My mistake, obviously I removed two cities copying to a text editor (King's Lynn & Kingston).
Therefore I didn't see it anymore.

Joffm

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

Lime-years ahead

Online-surveys for every purse and purpose