Copy link to clipboard
Copied
In Adobe Acrobat Pro I am trying to add fields depending on different column. I have no idea where to start. I already tried to use the Sum fuction of Adobe but here I can only select fields. Can someone please help me here? Maybe JavaScript or another solution?
Tha Table below shows what i am trying to achieve.
| 20 | A |
| 30 | B |
| 40 | C |
| 50 | A |
| 60 | B |
Col1 ist contains number fields Col2 contains only one Char e.g. A, B or C.
I am trying to add all values Col1 where value of col2 is for example A.
Thanks
Copy link to clipboard
Copied
Let's say the fields are named Col1_1 to Col1_5 and Col2_1 to Col2_5. You can use this code as the custom calculation script of the field you want to sum up all of the "A" values:
var total = 0;
for (var i=1; i<=5; i++) {
if (this.getField("Col2_"+i).valueAsString=="A") {
total+=Number(this.getField("Col1_"+i).valueAsString);
}
}
event.value = total;
You can easily modify the code to add up the "B", "C", etc. values.
Copy link to clipboard
Copied
in the future, to find the best place to post your message, use the list here, https://community.adobe.com/
p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.
<"moved from using the community">
Copy link to clipboard
Copied
Let's say the fields are named Col1_1 to Col1_5 and Col2_1 to Col2_5. You can use this code as the custom calculation script of the field you want to sum up all of the "A" values:
var total = 0;
for (var i=1; i<=5; i++) {
if (this.getField("Col2_"+i).valueAsString=="A") {
total+=Number(this.getField("Col1_"+i).valueAsString);
}
}
event.value = total;
You can easily modify the code to add up the "B", "C", etc. values.
Copy link to clipboard
Copied
@try67 Thank you so much. Works perfect.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more