Average of a group of fields

A

apd8x

I have modified the Applicant Rating template in Infopath so that I
have four different radio button fields. I would like to take an
average of these fields. I inserted an expression box and put in the
formula (field 1+ field 2+field 3+field 4) div 4 and it works fine. My
problem is I want to be able to omit 0. So that if a person chooses a
value of 0 or undetermined for field 1 then the formula should only
divide by 3 and not 4.

Any help is appreciated. There is not much documentation on Infopath.


Anne
 
A

apd8x

Ok, I figured it out mathematically. But it's not the easy solution.
I used this formula in an expression box:

(Field1 + Field2 + Field3 + Field4) / (round(Field1 / (Field1 + 1)) +
round(Field2 / (Field2 + 1)) + round(Field3 / (Field3 + 1)) +
round(Field4/ (Field4+ 1)))

That way if a value is 0 it is not equated into the average. The only
other problem was that when you intially open the form all fields were
set to 0 giving me a null error that displays as -1. #IND. To resolve
this I changed the Conditional Formatting under the Display tab to
have the rule:

If Field1=0 and Field2=0 and Field3=0 and Field4=0 then Hide this
Control.

My problem is solved. When a user opens the form no value will display
for average because all fields are set to 0. Once a user choses
difference ratings the average field will dynamically change. This is
as close as I could get the form to mirror the Applicant Rating
Template that comes with Infopath.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top