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

# Calculation

Community Beginner ,
Dec 27, 2022 Dec 27, 2022

Copied

Trying to calcuate a few fields into one formula

I need a formula for the below:

("UnitTypeTally.0.0" * "#ofUnitsTally.0.0") + ("TotalTally.0.0")

("UnitTypeTally.0.1" * "#ofUnitsTally.0.1") + ("TotalTally.0.1")

.......

("UnitTypeTally.0.15" * "#ofUnitsTally.0.15") + ("TotalTally.0.15")

TOPICS
Create PDFs , Edit and convert PDFs , JavaScript , PDF forms

Views

422

Report

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

Community Expert , Dec 27, 2022 Dec 27, 2022

try like this:

var a = Number(this.getField("UnitTypeTally.0.0").valueAsString);
var b = Number(this.getField("#ofUnitsTally.0.0").valueAsString);
var c = Number(this.getField("TotalTally.0.0").valueAsString);
if(a&&b&&c)
event.value = a*b+c;
else
event.value = "";

9 Replies 9
Community Expert ,
Dec 27, 2022 Dec 27, 2022

Copied

try like this:

var a = Number(this.getField("UnitTypeTally.0.0").valueAsString);
var b = Number(this.getField("#ofUnitsTally.0.0").valueAsString);
var c = Number(this.getField("TotalTally.0.0").valueAsString);
if(a&&b&&c)
event.value = a*b+c;
else
event.value = "";

Report

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

Copied

This will not produce a result if any of the fields is zero or empty, though. That's no necessarily how you want such a sum to work...

Report

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

Copied

I tried the above and it didn't work. UnitTypeTally.0.0 is a dropdown where each has option has an output value. Does that attribute to it not working? Because even with something entered into all fields, it didn't return a number

Report

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

Copied

It should still work if you added number as export value for dropdown choice.

It will calculate when all 3 fields have a value.

Do you have any error in console?

Can you share your file with us?

Report

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

Copied

I have attached the page. I appreciate the help. I am trying to learn all of this on the fly through trial and error and reading articles when I can. A lot more difficult than I anticipated.

Report

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

Copied

There is no "TotalTally.0.0" field in your file.

Report

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

Copied

Typo error on my end. That should be "TotalNetTally.0.0"

Report

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

Copied

In your first post you wrote:

("UnitTypeTally.0.0" * "#ofUnitsTally.0.0") + ("TotalTally.0.0")

but in your file, you are trying to calculate:

"TotalTally.0.0" = "#ofUnitsTally.0.0" * NetPerUnitTally.0.0

What exactly fields are you trying to multiply?

Also in all dropdown fields go to field properties and under 'Options' tab check 'Commit selected value immediately'.

Report

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

Copied

LATEST

Your first response worked. Once I changed it from "TotalTally.0.0" to "TotalNetTally.0.0" I got the desired results.