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")
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 = "";
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 = "";
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...
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
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?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
There is no "TotalTally.0.0" field in your file.
Copy link to clipboard
Copied
Typo error on my end. That should be "TotalNetTally.0.0"
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'.
Copy link to clipboard
Copied
Your first response worked. Once I changed it from "TotalTally.0.0" to "TotalNetTally.0.0" I got the desired results.