Skip to main content
Participant
July 16, 2025
Question

If/Sum Formula

  • July 16, 2025
  • 1 reply
  • 129 views

I have a bank deposit form I created where I want Adobe to add up certains fields based on criteria in another field. 

 

I have two different types of fields I want to incorporate into the formula.

Field A1 is the amount $100

Field B1 has the word "Cash" listed

 

Field A2 is the amount $200

Field B2 has the word "Check" listed

 

In my Total Cash and Total Check fields I am looking for a formula that will go down through the 16 lines of possible deposits where there might be Cash or Check listed and tally up all the Cash in one field and Check in another.

 

I know in excel it would be a simple IF statement and I could do it in my sleep...but my knowledge of JavaScript in Abode is null

1 reply

try67
Community Expert
Community Expert
July 16, 2025

You can use this code as the custom calculation script of the Total Cash field (and it can be re-used for the Total Check with a minor adjustment of the string in the 3rd line):

 

var total = 0;
for (var i=1; i<=16; i++) {
	if (this.getField("B"+i).valueAsString=="Cash")
		total+=Number(this.getField("A"+i).valueAsString);
}
event.value = total;