Skip navigation
PeptoBismolMonk
Currently Being Moderated

Need help with sum of 2 fields minus 1 field

Jul 13, 2012 9:09 AM

Hello,

 

I have been trying to obtain a total difference between 3 fields to be formulated for my final field at the bottom of my document.

 

Here is an example since the document is on a secure network.

 

Example:

 

Field 1 - (Field 2 + Field 3) = Total Difference (in my case I want this to equal Zero)

---------

 

I have tried multiple different custom formulas but so far either get a syntax error with script or it allows the script to be entered but the will not work once I begin to fill out the form to test out all of its applications.

 

so far I have found:

 

[Field# merely where the real title would be placed]

 

var v1 = getField("Field1").value;

var v2 = getField("Field2").value;

event.value = v1 - v2;

 

--------

 

This formula I believed would work but even without restructing it to fit my own requirements this formula did not gather any information nor caluclate it but merely left a big old Zero in the section I wanted the fields calculated difference to be entered in.

 

Any help with this issue would be greatly appreciated.

 
Replies
  • George Johnson
    9,232 posts
    Aug 11, 2002
    Currently Being Moderated
    Jul 13, 2012 9:42 AM   in reply to PeptoBismolMonk

    To use the simplified field notation option, be sure there are no spaces in the field names and the following should work:

     

    Field1 - Field2 - Field3

     

     

     

    The following custom Calculate script should do the same thing:

     

    (function () {

     

        var v1 = +getField("Field1").value;

        var v2 = +getField("Field2").value;

        var v3 = +getField("Field3").value;

     

        event.value = v1 - v2 - v3;

     

    })();

     

     

    Also, be sure that the field calculation order is correct. If you don't know what this is, post again.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points