4 Replies Latest reply on Jan 9, 2012 9:03 AM by try67

    Creating Custom Calculation formula

    Stefferkay33

      My problem is calculating the formula ((#Selectedfields>/=1.0) + (0.5(#selectedfields=0.5)) - (#selected fields <0.5) / (#selected fields evaluated)) *100

      The form will allow users to rate a certain field and have the percentage show up in my calculation box.  The kicker is the user can leave a field blank hence screwing up my #of selected fields evaluated.  My problem starts and ends with wording of the formula in the custom calculation box.  Can anyone help???

        • 1. Re: Creating Custom Calculation formula
          try67 MVP & Adobe Community Professional

          Provide some more details, please...

          How are the fields selected? What code are you currently using?

          • 2. Re: Creating Custom Calculation formula
            Stefferkay33 Level 1

            the user is allowed to rate each category between 1.5 through -1 in increments of .5 this is made possible with the properties box and selecting the options and then items.

             

            I don't have a correct code written for this formula.

            • 3. Re: Creating Custom Calculation formula
              Stefferkay33 Level 1

              (function() {

                 // Get the field values, as numbers
                 var v1 = +getField("Leadership").value;
                 var v2 = +getField("Training").value;
                 var v3 = +getField("BuildingFacilities").value;
                 var v4 = +getField("TechnicalStandards").value;
                 var v5 = +getField("WrittenProcedures").value;
                 var v6 = +getField("Validation").value;
                 var v7 = +getField("Housekeeping").value;
                 var v8 = +getField("MaterialControl").value;
                 var v9 = +getField("MakingOperations").value;
                 var v10 = +getField("PackingOperations").value;
                 var v11 = +getField("Storage").value;
                 var v12 = +getField("LaboratoryControl").value;
                 var v13 = +getField("ProcessControl").value;
                 var v14 = +getField("InProcess").value;
                 var v15 = +getField("Records").value;
                 var v16 = +getField("InternalAuditProgram").value;
                 var v17 = +getField("LearningResponse").value;
                 var v18 = +getField("TrackingImprovement").value;
                 var v19 = +getField("Accountablility").value;
                 var v20 = +getField("SafetySecurity").value;

              // Perform the calculation
                 var result = 100 * (var>/=1.0) + (0.5(var=0.5)) - var<0.5)/var evaluated;

                 // Set the value of this field to the result
                 event.value = result;
              })();

               

              I don't know how to get the variable that aren't rated subtracted from the var evaluated. 

              • 4. Re: Creating Custom Calculation formula
                try67 MVP & Adobe Community Professional

                Your code doesn't make sense. The word "var" is reserved to define a new variable. You can't use is as a name of a variable. Nor can you use it in the middle of a calculation to define a new variable out of the blue. Also, you're not doing anything with those 20 variables you define in the beginning of the code...

                 

                Are all of those fields radio-buttons? If so, then you need to first check if their values are "Off" (ie, none of them is selected), and then use that in your formula.

                1 person found this helpful