Welcome to the LimeSurvey Community Forum

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

Adding the Total & Average of a set of Questions

  • rock049
  • rock049's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 21 hours ago #183563 by rock049
I want to simply add the results of a set of questions within another question (which will be hidden) so it will show up in the database. So if I have Q1, Q2, Q3, Q4, and Q5 which are all Question Type: List (radio) and the resulting answers will show numbers 1-5 for each of the answers selected I would like Field T1 (Question Type: Equation) to include the sum of those numbers. I tried to input a couple of different options like Q1+Q2+Q3+Q4+Q5 or {SUM(Q1,Q2,Q3,Q4,Q5)} into the Question but the first one one sent me all the numbers not the totals and the second one has an error in the logic file which I have attached. I assume this equation goes in the Question field not in the Equation field but I have tried it in both places.

I would also like to do this for the average of these questions. So if I have Q1, Q2, Q3, Q4, and Q5 which are all Question Type: List (radio) and the resulting answers will show numbers 1-5 for each of the answers selected I would like Field A1 (Question Type: Equation) to include the average of those numbers. I assume that if I get the correct syntax above that the average syntax might be something like {SUM(Q1,Q2,Q3,Q4,Q5) / COUNT(Q1,Q2,Q3,Q4,Q5)} or something like that since I do not see an average function in EM.

I searched through the Forum but did not find anyone who seemed to have addressed this question. I would appreciate any direction on what I am missing in my syntax or where I am placing the syntax.

The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 16 hours ago #183568 by DenisChenu
Replied by DenisChenu on topic Adding the Total & Average of a set of Questions
sum !== SUM :).

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.
  • rock049
  • rock049's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 12 hours ago #183591 by rock049
Changing to a lower case of SUM {sum(Q1,Q2,Q3,Q4,Q5)} passed the logic check however the result is 0 (see Responses attached)

If I simply do this Q1+Q2+Q3+Q4+Q5 it will give a result something like this 3+3+5+2+2 (based on the Codes and Answers you see attached).

What is causing the 0 in this question field after running through an assessment?


The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 12 hours ago - 5 years 12 hours ago #183593 by tpartner
Try:

Code:
{sum(intval(Q1), intval(Q2), intval(Q3), intval(Q4), intval(Q5))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 12 hours ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • rock049
  • rock049's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 11 hours ago #183597 by rock049
Unfortunately that still resulted in "0"
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 hours ago #183602 by Joffm
Hi,
instead of talking too much without exact knowledge, please send us your sample *.lss.
I just created your design, 5 radio questions with codes 1-5, equation question {sum(Q1,Q2,Q3,Q4,Q5)}
And got the correct result.

Version 3.15.5+181115

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • rock049
  • rock049's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 hours ago #183607 by rock049
Here it is, thanks!


File Attachment:

File Name: limesurvey...4444.lss
File Size:57 KB



Version 3.17.2+190408
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 hours ago #183609 by DenisChenu
Replied by DenisChenu on topic Adding the Total & Average of a set of Questions
Can you create a new survey, with only this 5 questions and check again …

If some question have relevance, you must use .NAOK

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.

Lime-years ahead

Online-surveys for every purse and purpose