Welcome to the LimeSurvey Community Forum

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

Totalling one column from another (text Array)

  • baxterdmutt
  • baxterdmutt's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 month 6 days ago #269416 by baxterdmutt
LimeSurvey version:6.4.0-23128
Own server 

==================
I tried doing some searching but just can't seem to figure this out.
It is possible to have a text array and have one column calculate the amount x .50 of the column just before it.
Like this:
Question Q006 Column SQX003 would equal SQX002 X .50
If so where would I even put that calculation. I tried using "{sum(this.SQX003*.50)}"  and also "self" but just couldn't get it to be a valid variable.
I also can't figure out where to put the question so that the column I want the answer in fill itself in.
Sorry to be kinda dumb on this. 
I'm using text array because the first column is not numeric. All the other are.
Thank guys. 

Please Log in to join the conversation.

  • baxterdmutt
  • baxterdmutt's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 month 6 days ago #269417 by baxterdmutt
Replied by baxterdmutt on topic Totalling one column from another (text Array)
Well I figured out that this {sum(that.Q006.sq_SQX006.NAOK)} will total the columns. It doesn't quite get me where I wanted to be but it's close. Can I have it put that total in one of the Row/Columns. Say in an Empty row at the bottom of the ARRAY. That I can't figure out yet.

Please Log in to join the conversation.

  • baxterdmutt
  • baxterdmutt's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 month 4 days ago #269432 by baxterdmutt
Replied by baxterdmutt on topic Totalling one column from another (text Array)
I still need help please!!! I figured out a lot of this but I'm trying to use an equation question to do a calculation(a percentage). Ho can I do that. I've been trying different things for hours with no real luck:
Q007_SQ001_SQX005=sum(that.Q007.sq_SQX002.NAOK)*(50/100)
{Q007_SQ001_SQX005=sum(that.Q007.sq_SQX002.NAOK)*(50/100)}
These comes back valid but do nothing. What am I doing wrong.
Iv've tried just doing
that.Q007.sq_SQX002.NAOK)*(50/100)
and
sum(that.Q007.sq_SQX002.NAOK)*(50/100)
etc.
Help please

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 4 days ago #269433 by Joffm
You'd better sent a lss export of this question and maybe a sketch of what you try to do.

Joffm 

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

Please Log in to join the conversation.

  • baxterdmutt
  • baxterdmutt's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 month 4 days ago - 1 month 4 days ago #269434 by baxterdmutt
Replied by baxterdmutt on topic Totalling one column from another (text Array)
I’m not close to it now but it should be simple to explain. I want to sum a sub question column. (That’s not a problem) then multiple that by 50%. And put the result in a text or equation question (ie Total: $= the result)
Last edit: 1 month 4 days ago by baxterdmutt.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 4 days ago #269451 by Joffm
Only this?

And put the result in a text or equation question (ie Total: $= the result)


Here in the help text of the question: {sum(self.sq_X003.NAOK)/2}

Or in a text display and all other questions: {sum(that.Q1.sq_X003.NAOK)/2}

 

Joffm

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

Please Log in to join the conversation.

  • baxterdmutt
  • baxterdmutt's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 month 4 days ago - 1 month 3 days ago #269457 by baxterdmutt
Replied by baxterdmutt on topic Totalling one column from another (text Array)
Wow! Thank you. I was sure I tried that. I must have had a typo because it works now.

Now I need to figure out how to display the result in $ format. Again, Iv'e gone searching but can't find it anywhere. Is it possible? EDIT: I should say I mean with 2 decimal points. So instead of showing 50 show $50.00
Last edit: 1 month 3 days ago by baxterdmutt.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 3 days ago #269473 by Joffm
1. round((Q1,2)

2. round(100.0*Q1)/100

And why shouldn't you display
The amount is ${round((Q1,2)}

You can even prefill a cell in an equation like {Q2_y1_x3='$'+round((Q1,2)}

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

Please Log in to join the conversation.

  • baxterdmutt
  • baxterdmutt's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 month 3 days ago #269486 by baxterdmutt
Replied by baxterdmutt on topic Totalling one column from another (text Array)
I did try that and it works if you have pennies but if you have say $50.00 it only shows $50 (no .00 pennies).
I saw there is number_format in the manual but it doesn't look like it allows for decimal placement either. I think I would need javascript to get what I want.
Thanks for helping.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 2 days ago #269495 by Joffm
In the manual you find the function "sprintf".
[url] www.limesurvey.org/manual/ExpressionScri...mplemented_functions [/url]





Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: baxterdmutt

Please Log in to join the conversation.

  • baxterdmutt
  • baxterdmutt's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 month 1 hour ago #269527 by baxterdmutt
Replied by baxterdmutt on topic Totalling one column from another (text Array)
@Joffm Thank you so much for your help. It's working perfectly.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose