Skip to main content
Participant
November 19, 2018
Question

Help with null vs 0s Adobe Form Issue

  • November 19, 2018
  • 1 reply
  • 2320 views

I have 3 calculated fields.

Field1: sum of 5 values at timepoint1

Field 2: sum of 5  values at timepoint 2

Field 3: based on Field1 and Field2 sums ( it's a % change) --- (sum2-sum1)/sum1

The problem is this:

Field 2 is defaulting at 0 before anyone enters a 0. It should be null until a value is entered. Valid values can be 0,1,2,3,4 etc. anything greater or equal to 0.

Field 3 is then calculating before Field 2 has a valid entered value - because of the default 0 for Field2. I need it to calculate when an actual >=0 value is entered for field2.

How can I do this? I've tried so many options - the typical event.value==0 et.et. But i need to figure out with my limited javascripting how to ....any help will be awesome.

Example below:

the 10= FIELD1

Field 2: Diameter (mm) value = 0 because nothing is entered in the rows above - see all NULLS

Field 3: From BASELINE = -100 because its' calculating percent change from (0-10/10)  *100 = -100. I need the 0 only to be calculated if that sum really is 0 vs null as it is now

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
November 20, 2018

How did you set up the calculation? If you used a script, post it, please.

Participant
November 20, 2018

Ok thanks: Here are my calculations

Field1: diameter baseline sum : sum function in the text field properties

I also have this in the validate :

   // null filed value if entry is zero

     if(event.value == 0) event.value = "";

Field2:

Diameter 2 --- sum function in text field  ( where the sum default is 0)

with this in validate:

   // null filed value if entry is zero

     if(event.value == 0) event.value = 0

Field 3:

% change from baseline ( the one with the -100 when no field2 is entered but hte default is 0)

in calculate:

var baseDiaSum = this.getField("BASEDIAMETERSUM1").value;

var Dia2 = this.getField("DIAMETERSUM2").value;

if((!baseDiaSum) || (baseDiaSum == 0) ){

event.value = 0;

}

else{

event.value = ((Dia2 - baseDiaSum)/baseDiaSum)*100

}

in validate i was playing around with it and put this for now:

   // null filed value if entry is zero

     if(event.value ==0) event.value = "n/a";

try67
Community Expert
Community Expert
November 20, 2018

Can you share the actual file (using Dropbox, Google Drive, Adobe Cloud, etc.)?