Skip to main content
Gary8178
Participant
Feb 12, 2019 1:03 AM UTC
Question

On Adobe XI Pro form tool how do I write a calculation such as excel formula =IFERROR(G14/C14,"")?

On Adobe XI Pro form tool how do I write a calculation such as excel formula =IFERROR(G14/C14,"")? When the form is blank the cell is not acting correctly with a return of zero ($0.00). Current simple field notation is PV1/OP with the return in a %.

This topic is closed to new replies. Start a new post to keep the conversation going.

14 replies

Legend
Feb 12, 2019 3:58 PM UTC

The script would be written by a programmer. Would you like resources to learn how to program JavaScript?

Translate
Gary8178
Gary8178Author
Participant
Feb 12, 2019 5:48 PM UTC

Is there a good source of information on how to program javascript?

Translate
Legend
Feb 12, 2019 10:14 AM UTC

I think you're right. Could go further with

(A+0) == 0 ? 0 : (B+0) / (A+0) )

but it really isn't "simplified". Crucially, I think it would leave beginners more confused, not less...

Translate
Legend
Feb 12, 2019 9:53 AM UTC

No, I'm saying it IS valid. I tried it in Acrobat X... like all simplified field notation, it compiles directly into JavaScript, and this looks valid to me.

Translate
try67
Community Expert
Community Expert
Feb 12, 2019 10:04 AM UTC

Oh really? Wow... I'll try it myself.

Translate
try67
Community Expert
Community Expert
Feb 12, 2019 10:08 AM UTC

It does work, but the results are not really desired, I think... If both fields are empty the outcome is "NaN", and if A is empty but B is not (and not 0) the result is Infinity. I still think a script is the best way of doing it.

Translate
try67
Community Expert
Community Expert
Feb 12, 2019 9:13 AM UTC

You can either check if the divisor is zero (or empty) first, or check if the result of the operation equals "Infinity" (no quotes). If that's the case, you know it was the result of division by zero, and then apply another value to it.

Keep in mind, though, that a percentage field can never be empty. Its default value is "0%", which is not always the correct result...

Translate
Legend
Feb 12, 2019 9:36 AM UTC

Did anyone know that this is valid in simplified field notation:

A == 0 ? 0 : B / A

I was susprised, and cannot find a specification...

Translate
try67
Community Expert
Community Expert
Feb 12, 2019 9:50 AM UTC

No, it's not. You need to use a script.

Translate
Legend
Feb 12, 2019 8:32 AM UTC

Acrobat allows a programmer to adds JavaScript code to do calculation and verification.  To handle the specific case here you would use getField to read the value of C14, and make sure it isn’t zero before dividing by it.

Translate