Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

trouble calculating empty fields

Avatar

Level 1

I have a calculation (script below) where DN or DV are not always part of the sum. Trouble is both DV and DN have to be filled in to get the result.

How can I script these 2 fields to where one or both are calculated?

SUM=(PD1*DN*DV[WD1*CT])/BPY

7 Replies

Avatar

Level 6

You need to clarify what you want. Are you saying that if either of those two fields are blank that you do not want to include them in the calculation?

What is the purpose of the inner square brackets?

Avatar

Level 1

It looks like we found an answer to my problem but I'm getting this error message.

My syntax calculates correctly but this error meg pops up.

 

Can you tell me what it means?

Avatar

Level 6

I can't see any error message. It must not have been included in the rest of the message.

And it looks like you responded via email and it included some personal info that you probably don't want on this public forum, but you can log in via the forum and edit your last post to remove it.

Avatar

Level 1

Hi. Thanks for your previous responses.  I'm getting an error msg when I open this form in Reader and start entering info into the fields that are included in my calculation. Here's what the error  box says:

Script failed (language is formcalc; content is xfa[0].form1[0].#subbform[0].WD1[0])

script=

Sum(PD1*DN/DV[WD1*CT])/BPY

Error: arithmetic over/underflow.

Can you tell me what this means? I can still get the result I want, but each time I enter a number into one of the calculated fields I get this error msg. I click OK in the error msg and can continue.

Thanks!

Avatar

Level 6

It may be attempting to divide by zero, which will occur when the BPY field value evaluates to zero. To avoid this, you should check its value and only do the division if the value of BPY is a non-zero number.

Avatar

Level 6

I just noticed there's another division in there, so you'd have to make sure all of the divisors are non-zero numbers.

Avatar

Level 10

Also, you don't need to use Sum(), it's for summing a range of values. And I'm not sure what's going on with the square brackets you're using - that looks really odd, the square brackets are used to denote instances of fields.

So your script should look more like:

$ = (PD1*DN/DV[WD1*CT])/BPY

Except, as I said above, I'm not sure what the value in the square brackets is doing.

Other than that you'll need to do as George said you'll need to script for the null values in the fields that are empty to stop the divide error. So you'll need an if statement that only fires once all the fields are filled in.