Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Calculating averages

Avatar

Level 1

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

4 Replies

Avatar

Level 6

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

Avatar

Level 1

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?