Results 1 to 8 of 8
  1. #1
    accessuser10 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2013
    Posts
    5

    Taking the Average of values in a report except for null values

    Hi all,



    I have a list of numbers in a report that I want to take the average of in that sections footer. The problem that I am having is that there are also null values that are causing me to get an error message when I try to calculate the average. Is there a formula I could use to take the average of every number I have in that field except for the nulls?

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Aggregate Avg function ignores Nulls. How are you trying to get the average that is causing an error?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'm guessing you're trying to average a calculated value or the denominator of your expression is 0

    you can try something like

    =iif(count(denominatorfield) = 0, 0, sum(numeratorfield)/count(denominatorfield))

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    accessuser10

    What was the error message you received?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Issue with IIf is that all parts must be able to be evaluated, even if it isn't the part returning value, otherwise will still error. Division by 0 cannot be evaluated.

    This should return Null if the Count = 0

    =Sum(numeratorfield) / IIf(Count(denominatorfield) = 0, Null, Count(denominatorfield))

    However, still don't know what the OP is doing.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    accessuser10 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2013
    Posts
    5
    I have created a form where a reviewer can type in a score for a project that an employee is working on. I then have a report that shows the average of all the projects grouped by employees. However some scores that are entered are just left as null because the employee is not evaluated on that review category for a particular project. So for example when the three values I want to take the average of are 100, a null value, and 90, I get an error that says Data Type Mismatch in Criteria Expression. However when I take the average without null values I do not get this error. Let me know if I am making sense or you need further detail

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You've restated the problem and I think we all understand what it is, we just don't know how you have things set up. perhaps if you supply a sample database it would be easier to give you direction.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Still don't know how you are doing this calculation. At least show the expression that is erroring.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 02-03-2013, 01:11 PM
  2. Hide Null Values in Report
    By rdr910 in forum Reports
    Replies: 10
    Last Post: 03-15-2012, 03:09 PM
  3. Replies: 3
    Last Post: 01-20-2012, 04:46 PM
  4. Replies: 3
    Last Post: 12-06-2011, 07:37 AM
  5. Replies: 5
    Last Post: 08-24-2010, 02:32 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums