4 Replies Latest reply on May 10, 2012 10:52 PM by trafficcop244

Calculating averages

I am new to LIveCycle and I am using 8.0. I am creating a form that I need to calculate the average of several boxes and then display the average in a different box. The problem is sometimes I will have nothing entered in some of the boxes and need those not to conunt toward the number they are averaged by.

I have no experiance writing scrips. I can get the simple calculations entered just fine but I am not sure how to do this. Can anyone help me?

Thanks,

Tyler

• 1. Re: Calculating averages

There are a couple of ways to approach this.  This example tries to keep it simple.  You probably need three calculations.  I'm guessing you need to add two groups of numbers and then find the average.

Calculations:  You need to add a group of numbers together.

You can name the fields the same and use FormCalc.

In the box that displays that total 1:

Sum(fieldname1[*])

In the box that displays total 2:

Sum(fieldname2[*])

In the field that displays the average:

if (fieldname2.rawValue != 0) {

(fieldname1.rawValue / fieldname2.rawValue)*100;

} else {

// Set field to blank (or whatever else you would want) here

}

If you do not need to display the totals, you make those fields hidden but still use them for you calculation

• 2. Re: Calculating averages

I am getting errors when I try to put in the script to the average box. I already have the box that has the different numbers added up but can't seem to figure out the other part.

Would it help if I sent you the form to know what I am working with?

• 3. Re: Calculating averages

send to pbeef2000@yahoo.com if you'd like

• 4. Re: Calculating averages

ok you should have it.