Welcome to the LimeSurvey Community Forum

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

Calculation with values from rollbar: sum, division, multiplication, ...

  • ALehner
  • ALehner's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 10 months ago - 6 years 10 months ago #152659 by ALehner
Hi there,

i have a question regarding calculations based on values from previous answers of the test person.


--> Lets say the question n°1 in question block (Q04) is:

"How much are you interested in sport activities at your university on a scale from 1 to 10"

--> the test person has a roll bar to answer the question and sets the roll bar to 5


--> question n°2 in question block (Q04):

"How important are sport activities for you in general on a scale from 1 to 10"

--> the test person has a roll bar to answer the question and sets the roll bar to 3


NOW, for the next question block (Q05), I want to calculate:

value from answer 1 / sum of values from all answers from Q04 --> 5/8 = 0.625

AND display the result from the calculation to the test person in question block (Q05) as part of the question.


What is the Code for such a calculation in Limesurvey (I am using the online version)?????

Could someone provide me the source code for this task or is it even possible?


Thank you very much in advance!
Last edit: 6 years 10 months ago by ALehner.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #152661 by tpartner
You can use Expression Manager to both calculate the result and pipe it into the question text. If you are using the default sub-question codes in Q04, try inserting something like this in the text of Q05:

Code:
{Q04_SQ001/sum(Q04_SQ001, Q04_SQ002)}

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: ALehner
The topic has been locked.
  • ALehner
  • ALehner's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 10 months ago #152665 by ALehner
Worked out! Thank you!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose