These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Looking for help with an If - then - else statement. In excel it is =IF(N1>0,(N1+N2+N3)/3,(N2+N3)/2)

Tbone4444
Registered: Jul 20 2011
Posts: 2
Answered

Hello,
 
I could really use some help with a formula. I'm assuming that it would go in the custom calculation script box. I would like the box to be the average of 3 other boxes only if box #1 is more than zero. Otherwise I would like it to average box #2 & #3 and ignore box #1. Thank you for any assistance you can provide! Sincerely, Todd

My Product Information:
Acrobat Pro 9.1.1, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You will have to use a custom JavaScript calculation and need to provide the necessary field names.

Since you are using Acrobat Professional for Windows, you have 2 programs within that product that you can create forms with, Acrobat and LiveCycle Designer. Both of these products use different languages or script syntax, so it is important to know which product you are using.

If you used Acrobat then your formula could read:

// establish the field names for the cells
var cN1 = "Text1";
var cN2 = "Text2";
var cN3 = "Text3";
// get the values of the fields
var nN1 = Number(this.getField(cN1).value);
var nN2 = Number(this.getField(cN2).value);
var nN3 = Number(this.getField(cN3).value);
// default result value average of N2 and N3
event.value = (nN2 + nN3) / 2;
// if nN1 > 0 the average N1, N2, and N3
if(nN1 > 0)
event.value = (nN1 + nN2 + nN3) / 3;

George Kaiser

Tbone4444
Registered: Jul 20 2011
Posts: 2
Accepted Answer
George,

You are the man! After a little tweaking of my spacing it worked perfectly! Thanks for your help, it's very much appreciated.