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!!
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
...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 :
...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.
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You can use simplified field notation and write your field names (field1+field2) *. 144
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)
Copy link to clipboard
Copied
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:
Copy link to clipboard
Copied
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?
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 .
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Totally agree.