- Posts: 16
- Thank you received: 3
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
how to use expressions manager to sum answers of arrays (text)
- mikebb
- Topic Author
- Offline
- New Member
Less
More
5 years 7 months ago - 5 years 7 months ago #173246
by mikebb
how to use expressions manager to sum answers of arrays (text) was created by mikebb
Hi
I'm trying the get my survey to calculate and save to the db subscale scores and totals.
I can get expressions manager to add the answer values from an array (5 point choice) question, eg:
This will show and save the answer to the db. the question type where the expression is entered is equation
But when the question type is a general array and the answer values are numeric (1,2,3..) the same expression won't calculate. I don't see a way to force the question to be considered as 'numbers only'.
I need a general array as the answers are categories with text descriptions (not just numbers, or yes/no..)
So... how do I do expressions maths on the array (general type) questions?
thanks!
I'm trying the get my survey to calculate and save to the db subscale scores and totals.
I can get expressions manager to add the answer values from an array (5 point choice) question, eg:
Code:
{sum(question1_SQ001.value, question1_SQ002.value)}
This will show and save the answer to the db. the question type where the expression is entered is equation
But when the question type is a general array and the answer values are numeric (1,2,3..) the same expression won't calculate. I don't see a way to force the question to be considered as 'numbers only'.
I need a general array as the answers are categories with text descriptions (not just numbers, or yes/no..)
So... how do I do expressions maths on the array (general type) questions?
thanks!
Last edit: 5 years 7 months ago by mikebb. Reason: clarity
The topic has been locked.
- mikebb
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 3
5 years 7 months ago #173250
by mikebb
Replied by mikebb on topic how to use expressions manager to sum answers of arrays (text)
OK i think i just found my answer. when the array's answer option codes are numeric (1,2,3..) then use:
{sum(question1_SQ001.code, question1_SQ002.code)}
.. yes?
{sum(question1_SQ001.code, question1_SQ002.code)}
.. yes?
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
5 years 7 months ago #173251
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic how to use expressions manager to sum answers of arrays (text)
Yes, and furthermore you can use the "that" variable.
manual.limesurvey.org/Expression_Manager....22that.22_variables
{sum(that.question1.NAOK)}
Joffm
manual.limesurvey.org/Expression_Manager....22that.22_variables
{sum(that.question1.NAOK)}
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: mikebb
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
5 years 7 months ago #173258
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 how to use expressions manager to sum answers of arrays (text)
I don't understand why you can not use the assessment values and qCode.value in a normal array. If I assign assessment values, this works for me:
Sample survey attached:
Code:
{sum(Q1_SQ001.value, Q1_SQ002.value, Q1_SQ003.value, Q1_SQ004.value)}
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: mikebb
The topic has been locked.
- mikebb
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 3
5 years 7 months ago #173282
by mikebb
Replied by mikebb on topic how to use expressions manager to sum answers of arrays (text)
thanks for the replies - problem solved. LS is so feature rich I just don't understand all the options yet (ie assessments get me very confused).
cheers
Mike
cheers
Mike
The topic has been locked.