Welcome to the LimeSurvey Community Forum

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

Use of Expression Manager to allow values for unchecked boxes.

  • gaartsen
  • gaartsen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 11 months ago #190804 by gaartsen
Hi,
I have a situation where the I have 4 options that can either be true or false.
I want to use multiple choice for the 4 answers, and add a value to "non" selected boxes in those cases where the option is false.
I tried to do that using this EM statement in the Relevance Equation of the main question.
FYI, Answers 2 and 4 are true.
{sum(if(G5Q00001_SQ001 == "Y", -1, 1), if(G5Q00001_SQ002 == "Y", 1, -1), if(G5Q00001_SQ003 == "Y", -1, 1), if(G5Q00001_SQ004 == "Y", 1, -1))}
I have tried with this as well:
{sum(if(G5Q00001_SQ001 == "1", -1, 1), if(G5Q00001_SQ002 == "1", 1, -1), if(G5Q00001_SQ003 == "1", -1, 1), if(G5Q00001_SQ004 == "1", 1, -1))}

I wanted to use this method so I can use nagative values when scoring all questions in the group.
This seemed to me a quite straight forward method, but when I do a Logic Check I see this
I am not quite sure what I do wrong, but it's clear something is not quite right.
Can anyone please shed a light on this?
Many thanks in advance.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago #190806 by holch
Can you attach a LSS file with just the relevant questions, so that we can have a look at it? I don't see an error immediately, at least not in the screenshot, in the text itself the =='1' is obviously wrong, but I in the screenshot it is correct.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: gaartsen
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago - 4 years 11 months ago #190807 by Joffm
Hi, which version of LimeSurvey.

In Version 3.18.0+190923 I see this:



Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 11 months ago by Joffm.
The following user(s) said Thank You: gaartsen
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago #190809 by holch
Looking at Joffm's screenshot and your's I see that LS is marking the first { as red. So your problem seems to be there and it looks like you have space between the { and the sum.

Take out the space there and at the end as well and see what happens.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: gaartsen
The topic has been locked.
  • gaartsen
  • gaartsen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 11 months ago #190812 by gaartsen
I noticed that too, but upon checking the actual statement, there are no spaces at all.
The LS even adds space between the "-" and the "1".
The topic has been locked.
  • gaartsen
  • gaartsen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 11 months ago #190814 by gaartsen
Thanks for the very quick replies everyone :)
I'm using Version 2.72.3+171020, as there seem to be a lot of changes going to Version 3.
Looking at your statement, I saw the missing curly brackets. I removed the curly brackets, and that seems to work OK. Will have to test the scoring though.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago #190818 by holch
Did you put this equation into the validation field of the question???

Because I thought you uses an equation question for this sum.

In the validation fields and the relevance equation you are not supposed to use curly brackets. I find it a little confusing, that in some places you need the curly brackets and in others you shouldn't use them. I would have made it a common rule, any equation needs to be wrapped with {} it is not that much of extra coding and it would be a clear rule.

I think the theory behind it is that in the validation and the relevance equation you can only include expression manager code and nothing else, so yes, in theory the system doesn't need the curly brackets, but I still find it confusing and not consistent.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: gaartsen
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago #190823 by Joffm
Oh, yes,
therefore my logic check looked very different.

And I thought he displays the sum below the question text or somewhere else later.


And again a reason always to send the lss export.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • gaartsen
  • gaartsen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 11 months ago #190829 by gaartsen
It's working OK. I really appreciate all your help.
irt. The LSS, would a .lsq have helped? If not, what does constitute "relevant sections"?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago #190830 by holch
LSQ doesn't really help for a couple of reasons:
1. It is only a question that needs to be imported into a survey. So we don't have the original settings and those could impact the behavior.
2. It is extra work for the helpers in the forum to create a new survey and a question group to later import your .LSQ. also, the language must be the same one as in the LSQ, which is extra work to find out. With the .LSS we just need to import a file and can start trouble shooting.

So it is always recommended to provide a LSS. Help us to help you.

It is a little bit more work for you, but at the end it is you asking for help, so this little extra work should be OK.

Also, you shouldn't just send the whole survey, because this also makes it difficult for us to see where the problem is. And you probably don't want to post your whole survey on the internet anyway. So best thing is to create a copy of your survey, delete all questions that have nothing to do with the problem and then export it as a LSS file.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: gaartsen
The topic has been locked.
  • gaartsen
  • gaartsen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 11 months ago #190831 by gaartsen
All makes perfectly sense. I will do so when the next question pops up.
Many thanks for all your help so far.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose