- Posts: 15
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Calculate with assessment values within an IF statement
- Ton
- Topic Author
- Offline
- New Member
Less
More
8 years 2 months ago #131368
by Ton
Calculate with assessment values within an IF statement was created by Ton
My survey contains 14 question groups.
At the end of the survey I display a result per question group in percentage.
For that purpose I have defined an equation type question (always hidden) summing up the assessment values of the answers.
e.g. DD1CALC for the question group DD1
So far so good... the percentage shows on the end page of the survey.
Now I would like to give the respondent some information at the end of the question group depending on the percentage achieved.
I therefore created an equation type question (not hidden) containing the following IF statement:
{if(DD1CALC<40,'You score less than 40% for these questions. You have still some work to do',if(DD1CALC>80,'You score more than 80% for these questions. You are well on the way !','You score average on these questions. I suggest you discuss your answers with your therapist'))}
This does not work. It appears as if EM can not evaluate the value behind my DD1CALC variable.
It does work if I copy the full calculation previously used in the definition of DD1CALC, but that means an incredible amount of work as my survey contains 128 questions in 14 different question groups.
Thanks a ton for any help.
At the end of the survey I display a result per question group in percentage.
For that purpose I have defined an equation type question (always hidden) summing up the assessment values of the answers.
e.g. DD1CALC for the question group DD1
So far so good... the percentage shows on the end page of the survey.
Now I would like to give the respondent some information at the end of the question group depending on the percentage achieved.
I therefore created an equation type question (not hidden) containing the following IF statement:
{if(DD1CALC<40,'You score less than 40% for these questions. You have still some work to do',if(DD1CALC>80,'You score more than 80% for these questions. You are well on the way !','You score average on these questions. I suggest you discuss your answers with your therapist'))}
This does not work. It appears as if EM can not evaluate the value behind my DD1CALC variable.
It does work if I copy the full calculation previously used in the definition of DD1CALC, but that means an incredible amount of work as my survey contains 128 questions in 14 different question groups.
Thanks a ton for any help.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 2 months ago #131370
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Calculate with assessment values within an IF statement
Is DD1CALC placed before your group-statement equation type question?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Ton
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
8 years 2 months ago #131381
by Ton
Replied by Ton on topic Calculate with assessment values within an IF statement
Hi Tony.
Thanks for your reply but DD1CALC is placed after the group-statement equation.
Hope you have an idea...
Regards
Thanks for your reply but DD1CALC is placed after the group-statement equation.
Hope you have an idea...
Regards
The topic has been locked.
- holch
- Away
- LimeSurvey Community Team
Less
More
- Posts: 11641
- Thank you received: 2738
8 years 2 months ago - 8 years 2 months ago #131382
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Calculate with assessment values within an IF statement
Well, here we go. If DD1CALC is placed after the question where you want to use it, how can this question use it? It is only calculated in the future...
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 8 years 2 months ago by holch.
The topic has been locked.
- Ton
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
8 years 2 months ago #131385
by Ton
Replied by Ton on topic Calculate with assessment values within an IF statement
Sorry. Got that wrong in my answer to you.
DD1CALC is calculated before I try to use it in my comments.
Hope you have an idea anyway.
DD1CALC is calculated before I try to use it in my comments.
Hope you have an idea anyway.
The topic has been locked.
- holch
- Away
- LimeSurvey Community Team
Less
More
- Posts: 11641
- Thank you received: 2738
8 years 2 months ago #131388
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Calculate with assessment values within an IF statement
Can you attach an example here? Of course not the 1.000.000 questions you mentioned, but one set, so we can look at it?
Which version of LS are you using?
Which version of LS are you using?
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.
- Ton
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
8 years 2 months ago #131394
by Ton
Replied by Ton on topic Calculate with assessment values within an IF statement
Hi Holch,
Thanks for picking up my question.
Attached you find an extract of the survey.
The subject is pretty sensitive (the impact of sexual abuse on children).
I hope you had no such experience in your youth as it may then contain triggers for you.
We are using LS 2.06
in the example, question IFTEST1 works fine, but means an awful lot of work.
Question IFTEST2 is the way I would like to do it, but it doesn't work.
Looking forward to hearing from you again.
Have a great day.
Thanks for picking up my question.
Attached you find an extract of the survey.
The subject is pretty sensitive (the impact of sexual abuse on children).
I hope you had no such experience in your youth as it may then contain triggers for you.
We are using LS 2.06
in the example, question IFTEST1 works fine, but means an awful lot of work.
Question IFTEST2 is the way I would like to do it, but it doesn't work.
Looking forward to hearing from you again.
Have a great day.
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 2 months ago #131398
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Calculate with assessment values within an IF statement
I think the editor is messing with your "<" and ">" operators. Replacing them with "LT" and "GT" respectively and introducing a space before and after the operator seems to work.
Modified survey attached:
Modified survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- Ton
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
8 years 2 months ago #131404
by Ton
Replied by Ton on topic Calculate with assessment values within an IF statement
Thanks again Tony, but to no avail....
Upon entering the first answer, the question disappears (??!!??) and never shows up again.
To take away some confusion, better to delete IFTEST1 as that one works and you may think that the problem is solved.
Hope you have some more ideas or am I approaching the border of what is possible with LS ?
Cheers, Ton
Upon entering the first answer, the question disappears (??!!??) and never shows up again.
To take away some confusion, better to delete IFTEST1 as that one works and you may think that the problem is solved.
Hope you have some more ideas or am I approaching the border of what is possible with LS ?
Cheers, Ton
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 2 months ago #131406
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Calculate with assessment values within an IF statement
Hmm...2 problems...
1) I modified "DD1CALC" and that broke the equation. :blush: I have fixed it in the attached.
2) The tfr_responsive template seems to be causing the disappearance. The attached works with the default and citronade templates.
1) I modified "DD1CALC" and that broke the equation. :blush: I have fixed it in the attached.
2) The tfr_responsive template seems to be causing the disappearance. The attached works with the default and citronade templates.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- tammo
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 966
- Thank you received: 219
8 years 2 months ago #131508
by tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Replied by tammo on topic Calculate with assessment values within an IF statement
We also saw this behaviour. There is a new version of the template for LimeSurvey 2.06.
Could you be so kind to test this newest version? You can find it at:
www.toolsforresearch.com/limesurvey-responsive-template
greetings from The Netherlands,
Tammo
Could you be so kind to test this newest version? You can find it at:
www.toolsforresearch.com/limesurvey-responsive-template
greetings from The Netherlands,
Tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 2 months ago #131515
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Calculate with assessment values within an IF statement
Seems to work fine Tammo.
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: tammo
The topic has been locked.