Welcome to the LimeSurvey Community Forum

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

scoring selected radio list answers from a list of one choice questions

  • Moonlight7
  • Moonlight7's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 8 months ago #138682 by Moonlight7
Hi everyone and thanks for the great work and support.

I'm new to LimeSurvey and have read through the manual and many forum posts trying to learn further than just doing the obvious simple things. I wish I could find a beginner step by step guide to learn LS better.

I appreciate your help on this one to start with:

I have a number of radio list type questions (Q1, Q2, Q3,..... etc) and each question has three different answers (A1, A2, A3). After answering all questions (selecting one answer, A1 or A2 or A3) I need to sum total all selected A1 answers and display the result with some text. I also need to repeat same with A2 and A3.

I tried the following in an equation type question but it's not working. It highlights the Q_A variables as undefined. What am doing wrong ?!

So your A1 total score is : {sum(Q1_A1, Q2_A1, Q3_A1, Q4_A1, Q5_A1)}
Your A2 total score is : {sum(Q1_A2, Q2_A2, Q3_A2, Q4_A2, Q5_A2)}
Your A3 total score is : {sum(Q1_A3, Q2_A3, Q3_A3, Q4_A3, Q5_A3)}

Cheers
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138683 by Joffm
Hi, Moonlight,
IMHO LS doesn't know, what to sum, if your answer codes are just "A1", "A2", or "A3" and you say "sum(Q1_A1,Q2_A1)".
So, set your answer codes to "1", "2", "3", and change the equation to
QResult1= {sum(if(Q1==1,1,0), if(Q2==1,1,0), if(Q3==1,1,0))}
QResult2= {sum(if(Q1==2,1,0), if(Q2==2,1,0), if(Q3==2,1,0))}
...
Then you have the count of the answers in the respective variables.

Best Regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Moonlight7
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138684 by Joffm
Hi, Moonlight,

to add something.
You can display the results directly in a question by saying:

The result of "1" is: {sum(if(Q01==1,1,0), if(Q02==1,1,0), if(Q03==1,1,0))}
The result of "2" is: {sum(if(Q01==2,1,0), if(Q02==2,1,0), if(Q03==2,1,0))}

in the question text.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Moonlight7, sjsls2016
The topic has been locked.
  • Moonlight7
  • Moonlight7's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 8 months ago #138685 by Moonlight7
Joffm, thanks so much for your help. It works great.
The topic has been locked.
  • Moonlight7
  • Moonlight7's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 8 months ago - 7 years 8 months ago #138686 by Moonlight7
Here is another issue.
I used the same for a multiple choice question (mCQ) this time but it doesn't seem to be working !
Each sub-question/ choice has a different score when checked. I need to sum the scores of all checked choices.
e.g. if SQ001 was checked it scores 25; SQ002 scores 20, SQ003 scores 4, and SQ004 scores 5.
There are many more choices but this is for demonstration purposes now.

I used the following in an equation type question but nothing is happening !

{sum(if(mCQ_SQ001== 'Y',25,0), if(mCQ_SQ002== 'Y',20,0), if(mCQ_SQ003== 'Y',4,0), if(mCQ_SQ004== 'Y',5,0) )}

What is wrong with this ?!

Cheers
Last edit: 7 years 8 months ago by Moonlight7.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138692 by DenisChenu
Show screenshot please : OIf you have error : EM show the exact error type in "title" of the error ...

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Moonlight7
  • Moonlight7's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 8 months ago #138708 by Moonlight7

DenisChenu wrote: Show screenshot please : OIf you have error : EM show the exact error type in "title" of the error ...

Denis


Thanks so much Denis, I fixed it your way but I still like to learn why the one here is not working since this seems the only way for me to learn advanced tricks in LS (by trial and errors and posting here).

Thanks so much for all you guys for your kind support.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138710 by holch
Well, it is not very easy for us to help just with the equation. Because there could be many errors (e.g. a typo in the question code, etc.).

So either a lss file with the example or at least a screenshot of the error message might help. We can't rebuilt every situation that is posted on the forum.

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

The topic has been locked.
More
7 years 5 months ago #143135 by sjsls2016
Hi there what could be possibly my error in this screenshot.
this is my code.

{sum(if(Q00001 == 1,1,0), if(Q00004 == 1,1,0), if(Q00007 == 1,1,0), if(Q00011 == 1,1,0) , if(Q00012 == 1,1,0), if(Q00017 == 1,1,0), if(Q00019 == 1,1,0), if(Q00025 == 1,1,0), if(Q00029 == 1,1,0), if( Q00030 == 1,1,0), if(Q00033 == 1,1,0), if(Q00036 == 1,1,0), if(Q00039 == 1,1,0), if(Q00041 == 2,1,0), if(Q00044 == 1,1,0))}

this is what I've got.

Thank you for the reply.
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #143147 by tpartner
Assuming the question codes are correct, I don't see a problem.

Try removing IF statements until the error goes away.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: sjsls2016
The topic has been locked.
More
7 years 5 months ago #143161 by sjsls2016
Thanks I tried removing it, it also rendered an error, I tried retyping the codes manually and when I make a mistake I don't use the mouse pointer to insert in the error but rather backspace on everything until I erase the error and correct it. Because strangely I notice it was the cause of the problem. Very strange problem. Thanks.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose