Copy link to clipboard
Copied
Hi,
I have a formula for calculating the %CV of a set of values. The formula is below. The problem is that if you enter another value in one of the "fill" cells and then change it back to the original number you end up with a different calculated value. Also if you delete the contents of the calculated cell and then click or tab out of it the value also changes. Any idea what can be the root cause here?
var average = this.getField("Text10").value;
var v = 0;
var fieldName = "fill";
var s = 0;
var sd = 0;
n = 6;
for (var i = 0; i < n; i++) {
v = this.getField(fieldName + i).value;
s = s + Math.pow((v - average), 2);
}
sd = ((Math.sqrt(s / n)) / average);
You need to make sure that the Average field is calculated before this field. You'll be able to set the calculation order in Form Edit mode, under More (or Other Tasks if you have an earlier version of Acrobat).
Copy link to clipboard
Copied
Why is that a problem? The calculation script gets executed each time the value of any field in the file changes. That's how it is supposed to work.
Copy link to clipboard
Copied
Sorry, maybe my explanation wasn't clear.
So if i have a series of values in there. Let's say 1,2,3,4,5,6 I get a CV value of 0.79. If I change the 1 to a 2 the CV changes to 0.43, but if I then change the 2 back to a 1 the CV recalculates as 0.47 instead of 0.79.
Same thing if I have the same series in there 1,2,3,4,5,6 the CV is calculated as 0.79, but if I clear the calculated value and then click elsewhere in the sheet the value is re-calculated as 0.49 even though none of the input values have changed.
Copy link to clipboard
Copied
Are the values of these fields calculated as well, or are they entered by the user manually? What about the "average" field?
Copy link to clipboard
Copied
Fill0 through Fill5 are entered manually. The average is calculated using the average function of the calculate tool within Acrobat and is the "Text10" argument in the CV calculation
Copy link to clipboard
Copied
You need to make sure that the Average field is calculated before this field. You'll be able to set the calculation order in Form Edit mode, under More (or Other Tasks if you have an earlier version of Acrobat).
Copy link to clipboard
Copied
Awesome! Thanks for the help. I thought it might be something simple but didn't think about that.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now