2 Replies Latest reply on Jan 9, 2016 7:23 PM by tammieh39733640

    I need to round a formula to .5


      I am working on a form that calculates the total of a review with a percentage.  They want to overall score to round to the nearest .5.  It's pretty basic formulas.  Here the example


      Section one is GA40 (section worth 40%)

      Section two is CCR (section worth 60%)

      Overall score is the total of GA40 plus CCR but rounded to a .5


      The formula from the excel spreadsheet looks like this: =MROUND(E55*0.4+E65*0.6,0.5)

        • 1. Re: I need to round a formula to .5
          gkaiseril MVP & Adobe Community Professional

          I believe you are rounding the result of a formula to the nearest multiple.


          I believe the following script will do the task:


          function GetField(cName) {
          // get field object with error chdecking;
          var oField = this.getField(cName);
          if(oField == null) app.alert("Error accessing field " + cName, 1, 0);
          return oField;

          function MRound(nValue, nNumber){
          // Returns a number rounded to the desired multiple.
          return Math.floor(nValue / nNumber) * nNumber;

          var oE55 = GetField("GA40");
          var oE65 = GetField("CCR");
          event.value = MRound(oE55.value * 0.4 + oE65.value * 0.6, 0.5)


          You will need to adjust the field names as necessary.

          • 2. Re: I need to round a formula to .5
            tammieh39733640 Level 1

            You are amazing!!!  It works and rounds perfectly to the format and form requirements.  Thank you soooooo much!