Welcome, Guest
Username: Password: Remember me

TOPIC: Array Numbers with Sum Validation

Array Numbers with Sum Validation 7 months 2 weeks ago #104368

  • chinaski
  • chinaski's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Thank you received: 1
  • Karma: 0
I want to do a Multiple Numeric Input question but as an array, like the Array Numbers question type, but where each column of answers sums to 100, as I can do with the Multiple Numeric Input. Is this possible?

To see what I mean, here is what it would look like

survey_array_numbers.png


The "now" and "future" columns should sum to 100, no individual answer should be greater than 100 or less than 0.

Is this possible?
The administrator has disabled public write access.

Array Numbers with Sum Validation 7 months 2 weeks ago #104374

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Yes, you can do this easily.

Here is what it looks like running:

numeric_array_sum_running.png


Here is the question design view:

numeric_array_sum_question_design.png


For the help text, you enter the following:
Total Now = {sum(self.sq_now)}
Total Future = {sum(self.sq_future)}

and this expands internally to look like this:

numeric_array_sum_help.png


Here is the actual question as a .lsq file

File Attachment:

File Name: limesurvey_question_192.lsq
File Size: 5 KB


The Expression Manager documentation explains how to use the self variable in more detail.
The administrator has disabled public write access.

Array Numbers with Sum Validation 7 months 2 weeks ago #104392

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
I neglected the requirement that that each value be between 0 and 100.

Here is the corrected question as .lsq file:

File Attachment:

File Name: limesurvey_question_18318.lsq
File Size: 5 KB



And the associated screenshot showing that it works:

numeric_array_sum_running_2014-02-02.png


The rest is the same.
The administrator has disabled public write access.
The following user(s) said Thank You: chinaski

Array Numbers with Sum Validation 6 months 3 weeks ago #105681

  • chinaski
  • chinaski's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Thank you received: 1
  • Karma: 0
Thanks for your replies to this and sorry for my late response. I didn't receive a notification that someone had responded to this thread.

I have tested out your question example and it does work very well.

Cheers.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.150 seconds
Donation Image