Welcome to the LimeSurvey Community Forum

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

calculating in text array field based on answers from other questions

  • gogi100
  • gogi100's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 months ago #240542 by gogi100
Please help us help you and fill where relevant:
Your LimeSurvey version: [3.2]
Own server or LimeSurvey hosting: local hosting
Survey theme/template: vanilla
==================
hi i have question type text array with the 1 row and the two columns. i need that answer field automatically filled based answers from others questions, those questions also text array with the 1 row and the two columns.. the calculation for my field q20/q16.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago - 2 years 3 months ago #240543 by Joffm
Hi,
read the manual about ExpressionScript.

You have to use a (hidden) question of type "equation", where you do the calculations and set the value in the next array.
Something like
{Q2_Y001_X001=Q1_Y001_X001/Q1_Y001_X002}

Adapt to your codes  and your calculation

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 3 months ago by Joffm.

Please Log in to join the conversation.

  • gogi100
  • gogi100's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 months ago #240545 by gogi100
i received on your code undefined variable

Please Log in to join the conversation.

  • gogi100
  • gogi100's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 months ago #240547 by gogi100
i resolved problem with next code Q33_SQ001_SQ001=Q20_SQ001_SQ001/Q16_SQ001_SQ001, but i have one more problem in question text array i have two field how i add next code


Q33_SQ001_SQ001=Q20_SQ001_SQ001/Q16_SQ001_SQ001
Q33_SQ001_SQ002=Q20_SQ001_SQ002/Q16_SQ001_SQ002

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #240557 by Joffm

i received on your code undefined variable

What else did you expect? Of course we can only provide the structure as long as you do not show exactly your question codes / subquestion codes, etc.

i have two field how i add next code

Insert both calculatios into the equation



 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • gogi100
  • gogi100's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 months ago #240558 by gogi100
my question Q33 is text array type with the one row and the two columns (subquest) SQ001 and SQ002. i have also the two questions Q20 and Q16 that are the text array with the one row and the two columns SQ001 and SQ002.
i used next code

if((Q20_SQ001_SQ001 == "0") OR (Q16_SQ001_SQ001 == "0"), Q33_SQ001_SQ001 == 0, Q33_SQ001_SQ001 == Q20_SQ001_SQ001 / Q16_SQ001_SQ001), if((Q20_SQ001_SQ002 == "0") OR (Q16_SQ001_SQ002 == "0"), Q33_SQ001_SQ002 == 0, Q33_SQ001_SQ002 == Q20_SQ001_SQ002 / Q16_SQ001_SQ002) i don't know that this code ok

Please Log in to join the conversation.

  • gogi100
  • gogi100's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 months ago #240563 by gogi100
if i set my above code question is not displayed in survey

Please Log in to join the conversation.

More
2 years 3 months ago #240571 by Matadeleo
Can you include a copy of your survey? It's quite hard to visualise your issue. You can attach the .lss file

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago - 2 years 3 months ago #240572 by Joffm
You are confused about the "comparison operator ==" and the assignment operator =".

Have a look at the manual about operators.

Joffm 

And do you really want to divide by "0"?
Your equation is something like{Q33=if(Q16==0, Q20/Q16)}

Furthermore your if-statement is wrong. The dyntax is the same as in Excel.
{if(condition, what to do if TRUE, what to do if FALSE)}

In the manual there are some examples, I think in 
"ExpressionScript How-to"

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 3 months ago by Joffm.

Please Log in to join the conversation.

  • gogi100
  • gogi100's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 months ago #240573 by gogi100
i corrected '==' to '=' but my question does not displays

Please Log in to join the conversation.

  • gogi100
  • gogi100's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 months ago - 2 years 3 months ago #240574 by gogi100
i attached my survey. the problems are questions 33 and 34. those questions does not displays in my survey 

File Attachment:

File Name: limesurvey...8498.lss
File Size:100 KB
Last edit: 2 years 3 months ago by gogi100.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago - 2 years 3 months ago #240577 by Joffm

You have to use a (hidden) question of type "equation", 

There are no questions of type "equation" in your survey.
And you placed your code in "relevance equation". This is something quite different.
Please, learn the basics, study the sample surveys that you find in the manual
[url] www.limesurvey.org/manual/ExpressionScript_sample_surveys/en [/url]

And please, send only the relevant questions.
It is really difficult for us to go through a survey with cyrillic letters.

But, as I am courteous (most of the time) I will fix it. and send back.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 3 months ago by Joffm.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose