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
  • mikebb's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 7 months ago - 5 years 7 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:
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
  • mikebb's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 7 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.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #173251 by Joffm
Yes, and furthermore you can use the "that" variable.
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
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 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:

Code:
{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.
The following user(s) said Thank You: mikebb
The topic has been locked.
  • mikebb
  • mikebb's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 7 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.

Lime-years ahead

Online-surveys for every purse and purpose