Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Addition depending on column values

New Here ,
Jul 31, 2025 Jul 31, 2025

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.

Col1 Col2
20A
30B
40C
50A
60B

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

231
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jul 31, 2025 Jul 31, 2025

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.

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2025 Jul 31, 2025

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">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2025 Jul 31, 2025

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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 01, 2025 Aug 01, 2025
LATEST

@try67 Thank you so much. Works perfect.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines