Copy link to clipboard
Copied
Javascript: SUM IF for Adobe PDF Forms
I am wondering if there is something like a SUM IF Function for adobe. Basically, I want the calculation to if Row1 Column 1 = I then add Row 1 Column 5 (and I would have this repeat to check all rows but that part is simple. I am just stuck on making a statement that will add another amount if that row's column has a particular field "I"
(Edited by Adobe Employee/Moderator: Title & Topics)
Copy link to clipboard
Copied
You can use something like this:
var total = 0;
if (this.getField("Text1").valueAsString=="I") total+=Number(this.getField("Text2").valueAsString);
if (this.getField("Text3").valueAsString=="I") total+=Number(this.getField("Text4").valueAsString); // etc.
event.value = total;
Copy link to clipboard
Copied
You can use something like this:
var total = 0;
if (this.getField("Text1").valueAsString=="I") total+=Number(this.getField("Text2").valueAsString);
if (this.getField("Text3").valueAsString=="I") total+=Number(this.getField("Text4").valueAsString); // etc.
event.value = total;
Copy link to clipboard
Copied
This was a great idea but for some reason it isn't working. I even tried editing it slightly but the value always remains at 0.
Copy link to clipboard
Copied
TOTAL_ROW_1 is 1.00 so it should be seeingthat the first this.getfield matches the string and add the 1.00 from TOTAL_ROW_1 to the default 0 variable and appear as 1.00 but for some reason it isnt.
Copy link to clipboard
Copied
You are a life saver it did work I just did not have the bottom line added.

