Skip to main content
cmvarga5
Known Participant
May 29, 2025
Answered

Multiple Calculations in Form Field (addition, subtraction, division and/or multiplication)

  • May 29, 2025
  • 1 reply
  • 458 views

I have a table that shows assets, liabilities, etc.

For example:

Asset 1

Asset 2

Total Assets (I just use the sum calculation included in Acrobat)

Liabilities 1

Liabilities 2

Total Liabilities (I just used the same sum calculation included in Acrobat)

Net Worth (Total Assets - Total Liabilities)

 

Then I have a Leverage form field where Total Liabilities/Net Worth - Liabilities (this is where I have trouble)

 

How do I enter the calculation for this properly in Acrobat?

 

Correct answer try67

You need to use a script, but if "Net Worth" is zero then you can't perform the calculation, as division by zero is not allowed. So you need to use something like this as the field's custom calculation script:

 

var v1 = Number(this.getField("Total Liabilities").valueAsString);
var v2 = Number(this.getField("Net Worth").valueAsString);
var v3 = Number(this.getField("Liabilities").valueAsString);

if (v2==0) event.value = "";
else event.value = (v1/v2)-v3;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 29, 2025

You need to use a script, but if "Net Worth" is zero then you can't perform the calculation, as division by zero is not allowed. So you need to use something like this as the field's custom calculation script:

 

var v1 = Number(this.getField("Total Liabilities").valueAsString);
var v2 = Number(this.getField("Net Worth").valueAsString);
var v3 = Number(this.getField("Liabilities").valueAsString);

if (v2==0) event.value = "";
else event.value = (v1/v2)-v3;
cmvarga5
cmvarga5Author
Known Participant
June 2, 2025

Oh my! Thank you for this @try67 ! I will give this a shot and update you if it has worked for me.

cmvarga5
cmvarga5Author
Known Participant
June 2, 2025

Hi @try67 ,

I think it works, but now I need it to be a percentage with 2 decimal places.

 

Should I put: 

if (v2==0) event.value = "";
else event.value = (v1/v2)-v3*100;