Expand my Community achievements bar.

sum calculations

Avatar

Former Community Member
I am having difficulty doing a simple calculation. I would like to total a column. I am not sure how to make the function. I press sum and I get

Sum(n1 [, n2...]). Give me an example how I should write this.



I am working on a time sheet and would like to total hours for each day of the week. So I have a column with days of the week and a column with hours and would like to get total. Please help.
1 Reply

Avatar

Level 7
"Sum" is the function name. the "(" and ")" mark the start and end of the passed parameters to the function. the "n1 [,n2...]" indicate that there is one required parameter and then any number of optional parameters. The description in the 'Scripting Reference" under LiveCycle Designer's "Help" is:



"Returns the sum of the non-null elements of a given set of numbers."



So one could enter numbers, the values form field names, or an array of a field name as parameters and get the sum of the values.



If I have a row of fields called "DailyHours" and have 7 of these fields I could code for the "Calculation" script for the row total using FormCalc:



Sum(DailyHours[0], DailyHours[1], DailyHours[2], DailyHours[3], DailyHours[4], DailyHours[5], DailyHours[6])



or



Sum(DailyHours[*])