4 Replies Latest reply on Dec 27, 2012 12:08 PM by MorkAfur

    Doing an average

    MorkAfur

      Title

      Doing an average

      Post


           If you have a single table with a "weight" field, how do you do an overall average on that field?

           The documentation seems to say that Average is only for hard coded values or fields in a related table.

           I've tried to create a separate table occurrence and constuct the average that way, but it still doesn't work.

           Assuming this average can even be done, would it be better to create a calculation for a field or put a button on the layout that runs a script (or maybe it doesn't matter)?

           My references don't help on this one.

           Thanks in advance.

           - m

        • 1. Re: Doing an average
          philmodjunk

               A summary field can compute an average.

               There is also the aggregate function of the same name, Average(). It would require a related table if your values are in separate records as they should be, but the summary field does not.

          • 2. Re: Doing an average
            MorkAfur

                 Right. I did forget about that. :)

                 ---------

                 I was actually trying to just average the top 10 records -- the 10 largest values.

                 So, in that case, I should write a script that does the sort, goes to the top, and walks down the table and adds things up in a set variable. Then I can decide when I hit 10 records using the loop exit via calculation step and set a global field.

                 Does this approach sound good?

                 Sorry I wasn't more specific in my original posting.

                 Thanks Phil!

                 -m

            • 3. Re: Doing an average
              philmodjunk

                   It will produce the correct value. It might be possible to setup a filtered portal for the top 10 and use a one row summary portal filter with the same filter to show an average. Such a value is strictly for display, you can't use it in a calculation, but it would avoid having to loop through your records to compute the average each time.

              • 4. Re: Doing an average
                MorkAfur

                     You d'man.

                     Thanks Phil! :)

                     - m