3 Replies Latest reply on Apr 5, 2011 12:28 PM by Lance748

    average value calculation

    Lance748

      I have about 20 fields, named A through T.

       

      I want field T to calculate the average of fields A through S, and ignore any fields that are blank.  I would use the built in average calculator, but the blank fields give it problems.  Does anyone know a script for this?

       

      Thanks.

        • 1. Re: average value calculation
          George_Johnson MVP & Adobe Community Professional

          What are your field names?

           

          In general, you'd loop through the fields and get their values using the valueAsString property, so you can distinguish between a blank value and a value of zero. Convert the string value to a number and keep a running sum and count of non-blank fields. You can then calculate the average given the sum and number of non-blank fields.

          1 person found this helpful
          • 2. Re: average value calculation
            gkaiseril MVP & Adobe Community Professional

            You can search the forums for 'average' and you should find a working script.

             

            Although you might want to have functions for count, sum and average that build upon one another. You could count the number of fields with a non-blank value, and then if the count is not zero, sum the fields and then compute the average. You would then have the functions available for other forms.

            1 person found this helpful
            • 3. Re: average value calculation
              Lance748 Level 1

              Thanks, I found one.