how to use expressions manager to sum answers of arrays (text)

More
1 year 11 months ago - 1 year 11 months ago #173246 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:
{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: 1 year 11 months ago by mikebb. Reason: clarity
The topic has been locked.
LimeSurvey Partners
More
1 year 11 months ago #173250 by mikebb
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?
The topic has been locked.
More
1 year 11 months ago #173251 by Joffm
Yes, and furthermore you can use the "that" variable.
https://manual.limesurvey.org/Expression_Manager_-_presentation#The_reserved_.22this.22.2C_.22self.22.2C_and_.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.
More
1 year 11 months ago #173258 by tpartner
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:

{sum(Q1_SQ001.value, Q1_SQ002.value, Q1_SQ003.value, Q1_SQ004.value)}



Sample survey attached:

File Attachment:

File Name: limesurvey...30-2.lss
File Size:26 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Attachments:
The following user(s) said Thank You: mikebb
The topic has been locked.
More
1 year 11 months ago #173282 by mikebb
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
The topic has been locked.

Start now!

Just create your account and start using Limesurvey today.

Register now