#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    11
    Rep Power
    0

    AVG of Different Fields - Ignore Null


    Using the following to calculate average and it works great but some classes have no grades entered and in those instances I need to ignore that field.

    HEAD
    Code:
    <script language="javascript" runat="server">
    function average(){
      var total=0, arglen = arguments.length;
      for (var i=arglen-1; i >= 0; i--){
        total+=Number(arguments[i]); 
      }
      return total/arglen;
    }
    </script>
    BODY
    Code:
    <%=(average(rs_student_query.Fields.Item("pd_01_gbook_grade"),rs_student_query.Fields.Item("pd_02_gbook_grade"),rs_student_query.Fields.Item("pd_03_gbook_grade"),rs_student_query.Fields.Item("pd_04_gbook_grade"),rs_student_query.Fields.Item("pd_05_gbook_grade"), rs_student_query.Fields.Item("pd_06_gbook_grade"), rs_student_query.Fields.Item("pd_07_gbook_grade"),rs_student_query.Fields.Item("pd_08_gbook_grade")))
    %>
    Any insight would be appreciated!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    11
    Rep Power
    0
    Not at all tied to this approach so any ideas, samples, etc would be great.

    Thanks again for looking!

IMN logo majestic logo threadwatch logo seochat tools logo