Skip to main content
Participant
January 31, 2020
Question

Sum values depending on values in other fields

  • January 31, 2020
  • 1 reply
  • 1127 views

Hi! I am trying to create an invoice form that will hold varying VAT tax percentages. Each row has both a total price before tax (Field A), and a number indicating the VAT % of that row (Field 1).

I would like to show the total sums for three different tax levels on the bottom of my form, where each field would preferably autopopulate with the sums for that tax %.

 

For example: Fields A, B, D, and G should be summed because fields 1, 2, 4, and 7 show the same number, while fields C, E, and F sum because fields 3, 5, and 6 show the same number.

 

I am not super familiar with javascript but assume I will need to use a hefty amount of if statements.

I've looked at this thread to try to figure it out but need some help figuring out how to code it for acrobat: https://stackoverflow.com/questions/50879417/sum-field-values-based-on-condition-in-another-field-in-javascript

 

I'm working directly in Acrobat, right clicking fields > properties > custom calculation script.

 

Would love to hear if anyone has tips!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 31, 2020

Your description is not very clear, I'm afraid. Are you trying to match the fields names with the numbers that correspond with the order in the alphabet? What does that have to do with taxes? Please clarify.

Participant
February 3, 2020

Thank you for checking in! The template I'm working on can be viewed here.

I want the numbers entered into the column titled "Belopp (SEK)" to sum automatically into the four bottom-left fields ("Moms 25%", "Moms 12%", "Moms 6%", and "Momsfritt") depending on the numbers entered into the column titled "Moms %".

 

Example:

The columns show these numbers

Belopp     Moms

100           25

100           12

100           25

 

The fields on the bottom left should then show this calculation

Moms 25% 200

Moms 12% 100

Moms 6% 0

Momsfritt 0

 

Thank you

Thom Parker
Community Expert
Community Expert
February 3, 2020

Ok, and what exactly is the calculation? 

How was the number 200 calculated?

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often