Welcome to the LimeSurvey Community Forum

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

How to do calculation base on the answer of previous questions.

  • tuguy83
  • tuguy83's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 6 months ago - 9 years 6 months ago #112739 by tuguy83
Dear all,

I need to design a question base on the answer of previous questions.

First I ask respendents' distance to work. Than my next question is if the respondents accept "distance to work" is 10 kilometers further if the road condition change. And it is a table!

For example
choice 1 (I put their current distance)choice 2 (10 km further)
{INSERTANS:49343X809X2152}{sum({INSERTANS:49343X809X2152}, 100)}

I want the real number of "current distance + 10km" appear in the case below "choice 2".
I try to use {INSERTANS:49343X809X2152}, than sum{{INSERTANS:49343X809X2152}, 100}, and it doesn't work.

I want to do this because compare with seeing "n kilometer further", the respondents may behave differently when they see the real number.

Could any one give me a solution please?????

Thanks!
Last edit: 9 years 6 months ago by tuguy83.
The topic has been locked.
More
9 years 6 months ago #112740 by Ben_V
Try:

- to use question code instead {INSERTANS}
=> {sum(PREVIOUS_QUESTION_CODE, 100)}

OR

- remove {} around INSERTANS:49343X809X2152
=> {sum(INSERTANS:49343X809X2152, 100)}

.

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • tuguy83
  • tuguy83's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 6 months ago - 9 years 6 months ago #112742 by tuguy83
Thank you very much for your answer.

But I haven't succeed yet.

I have tried both, I entre a "current distance = 111 km" than it appears in the table:

choice 1 (current)choice 2 (10 km futher)
111{sum(111, 10)}

with both of them.

How can I have "121" in the table instead of "{sum(111, 10)}"?


:(
Last edit: 9 years 6 months ago by tuguy83.
The topic has been locked.
More
9 years 6 months ago #112746 by Ben_V
I don't really know! it should work!

What's the question type for your array?
Which version of LS are you using?


Maybe:

try with a "huge free text" question type...

only paste {sum(q1, 100)}

/!\ obviously replace q1 by your correct question code for the entered number
.

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • tuguy83
  • tuguy83's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 6 months ago #112749 by tuguy83

Ben_V wrote: I don't really know! it should work!

What's the question type for your array?
Which version of LS are you using?


Maybe:

try with a "huge free text" question type...

only paste {sum(q1, 100)}

/!\ obviously replace q1 by your correct question code for the entered number
.



The question type is numerical input.(for asking distance)
The question type for the choice is Array (Multi Flexible) (Text) where there is this table.

I tried {sum(q1, 100)}, than in the table it appears "{sum(q1, 100)}".
I tried {sum(INSERTANS:49343X809X2152, 100)}, than in the table it appears "{sum(INSERTANS:49343X809X2152, 100)}"
The topic has been locked.
More
9 years 6 months ago #112751 by Ben_V
and if you place {sum(q1, 100)} in the question text it works or not?

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • tuguy83
  • tuguy83's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 6 months ago - 9 years 6 months ago #112752 by tuguy83
I edited this choice table in the question text. And I also tried to past it directly outside the table. It appears "{sum(a5,10)}",the question number is a5.

I'm using a online version (1.87) provide by our research institute. I'm a beginner, and I'm also the only user of limesurvey in our Lab.

Thank you for all your answers. I really appropriate all your help.

Ben_V wrote: and if you place {sum(q1, 100)} in the question text it works or not?

Last edit: 9 years 6 months ago by tuguy83.
The topic has been locked.
More
9 years 6 months ago #112753 by Ben_V
OK !!! to use this kind of syntax you need a recent LS release, for the less greater than 1.92....

with 1.87 you have to use ONLY javascript functions; More complicated..

It's probably time to ask your research institute to update to a recent version (or to install a 2nd platform) :whistle:

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The following user(s) said Thank You: holch, tuguy83
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 6 months ago #112754 by holch
OK, this explains a lot. You are trying to use a feature (expression manager), that was not yet available in your version (as far as I know it came in 1.9x). You'll probably have to do a JavaScript solution.

By the way: I can't believe your research institute is still on 1.87. You should seriously consider to update, because Limesurvey has gone a long way since then and the differences are like day and night.

Additionally I doubt that the 1.8x versions still receive security updates. It is not that big of a deal to install the new version and it is really worth it. You should talk to the person responsible there.

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.

Lime-years ahead

Online-surveys for every purse and purpose