• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Form Calculation: add a code to multiply a summed column

New Here ,
Aug 13, 2020 Aug 13, 2020

Copy link to clipboard

Copied

I am hoping to get help with a calculation to multiply a summed total by a fixed amount.  The example is on a timesheet which totals the stipend for all staff .  I would like to take the "project total field" and multiply it by .144 to calculate the cost of benefits plus wages.  I was able to figure out the sum of the stipend but I cannot figure out how to multiply the stipend total.

Thanks in advance for any help!!

 

form snapshot.JPG

TOPICS
How to , PDF forms

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Aug 14, 2020 Aug 14, 2020

Hey Nesa and Marietta:

 

I just noticed in the equations that you've posted, if you're employing the Simplified Field Notation method for the Total Project field, this is only calulating the total cost of benefits plus wages. 

 

The Total Cost of Project is actually a Grand Total, not the cost of benefit plus wages.  So the formula should be

 

Grand Total = Total Stipends +(Total Stipends * .144)

 

You need to add all of the stipend fields together then multipliy that total by .144; AND THEN, add the to

...

Votes

Translate

Translate
Community Expert , Aug 14, 2020 Aug 14, 2020

Share an example of how you named those fields.

 

That is why I specified in my initial reply about prefixing and suffixing.

 

If you've employed a field name that prefix a name like this : "Stipends.1" (without the quotes, of course)  then you can't use this field name in the Simplified field notation. 

 

Spaces, periods, underscores, dashes (or any other special characters that you've used for a field name) must be escaped with a back slash ( \ ) when you use Simplified Field Notation.

 

For example :

...

Votes

Translate

Translate
Community Expert ,
Aug 13, 2020 Aug 13, 2020

Copy link to clipboard

Copied

In the Project Total field you can use something like this:

 

 

var f= this.getField("Total");
var g = f.getArray();
var  v = 0.0;  
for (var i=0; i<=g.length; i++) {  
    event.value =
var subtotal = v += g[i].value; 
event.value = subtotal +(subtotal*.144);
}

 

 

This example is using the getArray() method so it is intended to work if you have a parent field prefixed and all the children fields suffixed.  If you use different fieldnames then you would need to employ a slightly different method to have the script calculate numerical fields with the new Array() method,for example. 

 

For my example, every field under the Total Stipends column I renamed to "Total.1", "Total.2", "Total.3", etc.  which made everything very easy and more organized. But this can be achieved in many other ways with JavaScript.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2020 Aug 13, 2020

Copy link to clipboard

Copied

I'm assuming you are using "Simplified field notation" to do calculations?
You want it to show result in total field? if yes then do like this:
if you just want to show .144 use: (field1+field2+field3)*.144
if you want to add .144 to "total" field sum use (field1+field2+field3)*1.144
Of course change field names to the names you are using.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

Thank you for your response. This calculation was my first thought but it
is not working for me...clearly user error! I am stumped and perhaps
overthinking the process.


--

Robin Kinn

Administrative Assistant

Park Community Charter School

509 Lawe Street | Kaukauna, WI 54130

kinnr@kaukaunasd.org | 920.766.6129

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

From what I got once you get total sum you want to multiply it by. 144 in what field do you want to show result from that? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

I want the result to show in the "project total" field. Can I sum and
multiply in the same field? #calculationnewbie
Thanks, for the help!

--

Robin Kinn

Administrative Assistant

Park Community Charter School

509 Lawe Street | Kaukauna, WI 54130

kinnr@kaukaunasd.org | 920.766.6129

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

You can use simplified field notation and write your field names (field1+field2) *. 144 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

Hey Nesa and Marietta:

 

I just noticed in the equations that you've posted, if you're employing the Simplified Field Notation method for the Total Project field, this is only calulating the total cost of benefits plus wages. 

 

The Total Cost of Project is actually a Grand Total, not the cost of benefit plus wages.  So the formula should be

 

Grand Total = Total Stipends +(Total Stipends * .144)

 

You need to add all of the stipend fields together then multipliy that total by .144; AND THEN, add the total SUM of all stipend fields. Otherwise, the current calculation only outputs the total for the cost of benefits plus wages.

 

It should be phrased like this :

 

field1+field2+field3+field4+field5+field6+field7+field8 +((field1+field2+field3+field4+field5+field6+field7+field8)*.144) 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

I feel completely inept...this phrase isn't working either. I checked for
errors; cannot figure out what I am missing.
I appreciate your patience and assistance!!

--

Robin Kinn

Administrative Assistant

Park Community Charter School

509 Lawe Street | Kaukauna, WI 54130

kinnr@kaukaunasd.org | 920.766.6129

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

We are just posting examples for the field names. 

 

With your document opened in  Acrobat, clicl on "Prepare Form"  then verify what are the fieldnames that you used in the form under the Total Stipends column.

 

The fieldnames that you assigned must be spelled exaclty the same way in whatever method of scripting  or calculation you employ.

 

See slide below:

 

SFN.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

I am using my field names, exactly as they are entered in the prepared form.

--

Robin Kinn

Administrative Assistant

Park Community Charter School

509 Lawe Street | Kaukauna, WI 54130

kinnr@kaukaunasd.org | 920.766.6129

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

When you say is not working what results are you getting?  Is the Project Total field completely blank or is it throwing the wrong numbers?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

Share an example of how you named those fields.

 

That is why I specified in my initial reply about prefixing and suffixing.

 

If you've employed a field name that prefix a name like this : "Stipends.1" (without the quotes, of course)  then you can't use this field name in the Simplified field notation. 

 

Spaces, periods, underscores, dashes (or any other special characters that you've used for a field name) must be escaped with a back slash ( \ ) when you use Simplified Field Notation.

 

For example :  Stipends\.1 + Stipends\.2

 

If your field names are prefixed, and you want to  use Simplified Field Notation, then  you need to phrase it like this:

 

Stipends\.1 + Stipends\.2 + Stipends\.3 + Stipends\.4 + Stipends\.5 + Stipends\.6 + Stipends\.7 + Stipends\.8) +((Stipends\.1 + Stipends\.2 + Stipends\.3 + Stipends\.4 + Stipends\.5 + Stipends\.6 + Stipends\.7 + Stipends\.8) +)*.144) 

 

Now, be advised that using Simplified Field Notation won't rond down the value automatically , it will always round up automatically.  While this is convenient you may want to consider how to work around this if you need the total to be precise, specially on governement forms .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

LATEST
The field is completely blank - no calculation. I am attaching the file.
I feel this is probably something simple and I am just completely missing
it.

--

Robin Kinn

Administrative Assistant

Park Community Charter School

509 Lawe Street | Kaukauna, WI 54130

kinnr@kaukaunasd.org | 920.766.6129

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

I was just giving him example how to use SFN, was hoping he would figure it out what he needs from there. It would be nice if he can share his file cuz just saying code doesn't work don't tell us much unless explain what the problem is. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

Totally agree.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines