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

Calculation

Community Beginner ,
Dec 27, 2022 Dec 27, 2022

Copy link to clipboard

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

Translate

Translate

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 guidelines

correct answers 1 Correct answer

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 = "";

Votes

Translate

Translate
Community Expert ,
Dec 27, 2022 Dec 27, 2022

Copy link to clipboard

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 = "";

Votes

Translate

Translate

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 guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

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...

Votes

Translate

Translate

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 guidelines
Community Beginner ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

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

Votes

Translate

Translate

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 guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

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?

Votes

Translate

Translate

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 guidelines
Community Beginner ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

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. 

Votes

Translate

Translate

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 guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

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 guidelines
Community Beginner ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

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 guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

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'.

Votes

Translate

Translate

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 guidelines
Community Beginner ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

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 guidelines