Welcome to the LimeSurvey Community Forum

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

Defining Equation Variables

  • elunden
  • elunden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 days ago #182262 by elunden
Defining Equation Variables was created by elunden
Hello,

I want to have the sum of a group of scores emailed back to the admin email. I follow the directions in a forum by creating a hidden question with an equation. But the equation is not working.

There is a query that needs to be added somewhere... given that I do not code, I am not sure where this needs to be pasted. So, I get the attached error.

Can someone help me by telling me what I am missing and where I need to paste it?
Thanks so much!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 days ago #182263 by Joffm
Replied by Joffm on topic Defining Equation Variables
Of what type are the two questions? If both questions are numerical your equation looks fine; are the curly brackets there?

Anyway, your question is a bit confusing.
First you talk about a

sum of a group of scores


But afterwards you mention a

a query that needs to be added somewhere


So, best you send a small example (*.lss) with the questions that are to be summed up.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • elunden
  • elunden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 days ago #182264 by elunden
Replied by elunden on topic Defining Equation Variables
Yes, the curly brackets are there.

When someone takes the survey, they can get the results on their scores at the end, but there is no way to save the scores in the database. So, I would like the scores to be included in the admin email notification using hidden questions.

I have another survey that does this but I am not sure what I am missing here and why this one is not working...

See small sample attached.
Thanks!
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 days ago - 5 years 2 days ago #182266 by holch
Replied by holch on topic Defining Equation Variables
First problem is, that there is no such thing like Q0002.valueNOAK, because you are using various subquestions in a array type question. This is why you get an red frame around your Q0002.valueNOAK. If you go over it, Limesurvey tells you that this value is not defined.

Also, one tip when using those things: don't hide the question while devolping the questionnaire, because what these questions show can help you to understand if something is going wrong, or better to check if everything is alright. Once everything works you can still hide the question (here your equation). And you either hide it with "Always hide" or you hide it with the css class hidden, you don't need both. In this case it is OK to go for always hide.

You would need to create first the sume of these subquestions, with something like this:
Code:
{sum(Q0002_A1.valueNAOK, Q0002_A2.valueNAOK, Q0002_A3.valueNAOK, Q0002_A4.valueNAOK, Q0002_A4.valueNAOK)}

Tested this, works like a charm. Now we need to find out what is wrong with Q0002B.

OK, that was easy. Same problem. You are using an array question. So with Q0002B, what subquestion are you referring to, just like above. Yes, in this case it is simple, as there is only one subquestion, but LS and the Expression Manager are stupid and like to be told exactly what to do, so just like before, you need to tell LS which subquestion you are referring to, especially as you name your subquestions pretty strange (Ax, which is generally the default value for the answer codes and not the subquestion codes in LS).

So at the end of the day, your equation should look like this:
Code:
sum(Q0002_A1.valueNAOK, Q0002_A2.valueNAOK, Q0002_A3.valueNAOK, Q0002_A4.valueNAOK, Q0002_A4.valueNAOK, Q0002B_A1.valueNAOK)

Tested, works like a charm, summing up all the assessment values of all the subquestions.

I did not look at the second question group, but it looks like they have the same structure and thus the problem is most probably the same.

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

Last edit: 5 years 2 days ago by holch.
The following user(s) said Thank You: DenisChenu, cdorin
The topic has been locked.
  • elunden
  • elunden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 2 days ago #182270 by elunden
Replied by elunden on topic Defining Equation Variables
Yes! Worked like a charm. Your explanations made sense. Thanks so much for your help.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose