How to sum radio button answers

Plus d'informations
il y a 2 mois 1 semaine #185360 par Petteri66
Hi there,


I have 4 radio button questions (Q1, Q2, Q3, Q4) with each 4 answer possibilities (A1, A2, A3, A4).

Now I would like to sum e.g.:


sum(Q1_A4, Q2_A4, Q3_A1, Q4_A4)


I do get an error notice "undefined variable". What do I do wrong? Any hint is appreciated.


Petteri

Connexion ou Créer un compte pour participer à la conversation.

LimeSurvey Partners
Plus d'informations
il y a 2 mois 1 semaine #185362 par holch
Réponse de holch sur le sujet How to sum radio button answers
You get this error, because there is no such thing as Q1_A1, Q1_A2, etc.

As you have a single choice question (radio button), you can access the question only via Q1 with the result being A1, A2, A3, etc., which you can also not add, because they are not numbers, but strings.

Sum does not make any sense here. What exactly are you trying to do? I think you don't really want to sum here anyway, but rather count, correct?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185365 par Petteri66
Réponse de Petteri66 sur le sujet How to sum radio button answers
Hello Holch,

and thank you for the quick response.

I try to do following. I have 4 single questions with those 4 options. Each option is characteristic for one “style”. If the respondent choose e.g. in question 1 option 3, in question 2 option 1, in question 3 option 4 and in question 4 option 2, then “style 1“ gets the most “points”. The same method goes for the other 3 styles.

As you wrote, somehow I should count, how many “points” each style gets. How often option 1, option 2, option 3 and option 4 is chosen. Could I explain my problem?

Petteri

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185368 par DenisChenu
Réponse de DenisChenu sur le sujet How to sum radio button answers
Maybe you can have a look at manual.limesurvey.org/Assessments

And then sum(Q1.valueNAOK,Q2.valueNAOK,Q3.valueNAOK)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185378 par Petteri66
Réponse de Petteri66 sur le sujet How to sum radio button answers
Hello Denis,

and thanks for the message. I had already enabled assement modus. What i'm looking for is something like in the attached picture, where each answer option goes to specific "bucket" (blue, green... in my image) and then the sum for each bucket/color is counted.

Is this possible with radio buttons oder should I take an other approach with orher question type?


BR,

Petteri
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185381 par Joffm
Réponse de Joffm sur le sujet How to sum radio button answers
Hi, Petteri,
you do it exactly as you would explain it.
"if an object goes to bucket 1, increase the sum of bucket 1 by 1"
"if an object goes to bucket 3, increase the sum of bucket 3 by 1".

"if an object goes to bucket 1" means "if the code of the object is "A1"

I use your example of the first post

I have 4 radio button questions (Q1, Q2, Q3, Q4) with each 4 answer possibilities (A1, A2, A3, A4).

Create 4 questions of type equation (sumA1, sumA2,...)
The above translated to an equation:
sumA1:
{sum(if(Q1=="A1",1,0),if(Q2=="A1",1,0),if(Q3=="A1",1,0),if(Q4=="A1",1,0))}
...
sumA3:
{sum(if(Q1=="A3",1,0),if(Q2=="A3",1,0),if(Q3=="A3",1,0),if(Q4=="A3",1,0))}

Joffm


Please, read the manual about the if-statement, implemented functions and the question types


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Les utilisateur(s) suivant ont remercié: DenisChenu

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185383 par Petteri66
Réponse de Petteri66 sur le sujet How to sum radio button answers
Hi Joffm,

great, thank you so much. That did the job.

I'll dive a bit deeper in this if-statement.

BR,

Petteri

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185389 par tpartner
Réponse de tpartner sur le sujet How to sum radio button answers
The IF statements are similar to Excel...

{if(condition, returned if true, returned if false)}

You can also use nested IF statements to achieve IF ELSE (line breaks inserted for clarity)...

{if(q1 == 1, "Result 1", 
    if(q2 == 1, "Result 2", 
        if(q3 == 1, "Result 3", 
            if(q4 == 1, "Result 4", 
                "Result if none of the above true"))))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185400 par Petteri66
Réponse de Petteri66 sur le sujet How to sum radio button answers
Hi Tony,

yes, I noticed the similarity to excel, although == are for me not so familiar.

I will also test your solution, thank you.

Cherrs,

Petteri

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185430 par Petteri66
Réponse de Petteri66 sur le sujet How to sum radio button answers
Hi again,

I stil have one problem. The function sums only 3 out of 4 questions. The first one is left out. I think, I should have everything right and I can't see the mistake. Would you find the mistake in the following line:

sum(if(q1 == "A1", 1, 0), if(q2 == "A3", 1, 0), if(q3 == "A4", 1, 0), if(q4 == "A3", 1, 0))

BR,

Petteri

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185431 par Joffm
Réponse de Joffm sur le sujet How to sum radio button answers
Sorry,nor can we see it without your survey, or better these questions and the equations.
So, please provide it as *.lss

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185437 par Petteri66
Réponse de Petteri66 sur le sujet How to sum radio button answers
Hi Joffm,

enclosed you'll the questions as lsq-file.

Thank you,

Petteri
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185438 par holch
Réponse de holch sur le sujet How to sum radio button answers
Please always provide a LSS file. This makes it just so much easier for the helpers here in the forum. If you provide only a lsq file, we as the helpers can not just import it to our system, but need to create a survey first, then a question group and then we can import it into our survey. If we are unlucky, your lsq is not in the language we have created the survey in and thus can not be imported, so more work for us.

So, please create a copy of your survey, delete all unnecessary questions and question groups and just leaf the parts that are necessary to understand you problem.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185452 par Petteri66
Réponse de Petteri66 sur le sujet How to sum radio button answers
I'm sorry for my mistake! The difference and difficulties with lsq-file was not known for me.

Enclosed trhe lss-file.

BR,

Petteri
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 1 semaine #185465 par Joffm
Réponse de Joffm sur le sujet How to sum radio button answers
Hi, petteri,
it's a typical "GIGO" (Garbage in - Garbage out) error, which nobody of us would have found without seeing your survey.

Your codes in question q4 are °1°, "2", "3", "4", but in the equation you compare with "A1", "A2",...
So, either you change your equation accordingly:
Bucket 1: sum(if(q4 == 4, 1, 0), if(q5 == "A4", 1, 0), if(q6 == "A1", 1, 0), if(q7 == "A4", 1, 0))

or you change the codes of question q4.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!