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

Calculation

Explorer ,
Dec 27, 2022 Dec 27, 2022

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
1.6K
Translate
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
1 ACCEPTED SOLUTION
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 = "";

View solution in original post

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

Translate
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

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

Translate
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
Explorer ,
Dec 28, 2022 Dec 28, 2022

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

Translate
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

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?

Translate
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
Explorer ,
Dec 28, 2022 Dec 28, 2022

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. 

Translate
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

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

Translate
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
Explorer ,
Dec 28, 2022 Dec 28, 2022

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

Translate
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

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

Translate
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
Explorer ,
Dec 28, 2022 Dec 28, 2022
LATEST

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

Translate
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