Welcome to the LimeSurvey Community Forum

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

equation

  • VANBEERS
  • VANBEERS's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #199512 by VANBEERS
equation was created by VANBEERS
Hello,

Beginner, I hope to ask my question in the right place.

I carried out a first drowsiness questionnaire (Epworth) proposed for each of the 8 questions (EPW) 4 proposals (with assignment value) in the form of a radio list. As a result of the handover, I simply want a sum of the assignment values.
I created a last question (Q09) with an equation type response to perform this calculation. I inserted in the field "question" the formula:

{sum (that.EPW01.NAOK, that.EPW02.NAOK, that.EPW03.NAOK, that.EPW04.NAOK, that.EPW05.NAOK, that.EPW06.NAOK, that.EPW07.NAOK, that.EPW08.NAOK )}

to present the score to the respondent.

Whatever the answers, the sum is always zero.

Could you tell me about the mistakes made?

Thank you.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #199515 by Joffm
Replied by Joffm on topic equation
Hi,
There are several mistakes:
1. As EPW are list radio questions, do dont have to use "that".
"self" or "that" are used for quesions with subquestions, rows, columns.
Manual:

Quite often you want to evaluate all the parts of a question, such as counting how many subquestions have been answered or summing up the scores. Other times you want to process just certain rows or columns of a question (such as getting the row or column sums and storing them in the database). These reserved variables make that process relatively painless.


Let's take an array(numbers) with subquestions (Y001,Y002) and columns (X001,X002,X003)
So "sum(that.Q1)" would be extended to "sum(Q1_Y001_X001,Q1_Y001_X002,Q1_Y001_X003,Q1_Y002_X001,Q1_Y002_X002,Q1_Y002_X003)"

In your case you have a single punch question, So you just use ...?
Yes, what do you use?
As the manual says here:
manual.limesurvey.org/ExpressionScript_-...#Access_to_variables

{EPW01} - the code of the question - an alias for {EPW01.code}
and
{EPW01.code} - the selected response code for the question

2. And here your second mistake.
You do not want to sum up the selected code, but the assessment value.

Again in the manual
{EPW01.value} - the assessment value for the question

So finally your equation is
{sum (EPW01.valueNAOK, EPW02.valueNAOK, EPW03.valueNAOK, EPW04.valueNAOK, EPW05.valueNAOK, EPW06.valueNAOK, EPW07.valueNAOK, EPW08.valueNAOK )}

3. And your third one ;)

I hope to ask my question in the right place

This is obviusly not a "Installation & Update" issue.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #199519 by DenisChenu
Replied by DenisChenu on topic equation
I move it ;)


Design issues
Please report here if you have questions or problems how to setup your survey.

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.
  • VANBEERS
  • VANBEERS's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #200127 by VANBEERS
Replied by VANBEERS on topic equation
Thanks Joffm,

The answers and advice were very helpful to me. No mistake. Also, I was able to carry out very varied questionnaires, carry out tests and validation; which explains my late thanks.
Pascal
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose