+ Reply to Thread
Results 1 to 12 of 12

IF and AND statements then average the sum

  1. #1
    Registered User
    Join Date
    01-29-2015
    Location
    Wigan, England
    MS-Off Ver
    7
    Posts
    10

    IF and AND statements then average the sum

    Hi everyone,

    Hopefully somebody can help me with this one

    I'm using Excel 2013 on Office 365

    Column A Contains the 'Check Type' - this can be Core or Zone
    Column B contains the department - this can be 'ambient', 'chilled', or 'frozen'
    Column C contains time (00:00:00)

    I need a formula that deals with IF and AND statements and then returns an average of the sum e.g. it will look up all of the Core Ambient times and return an average of the total


    Thank you in advance

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: IF and AND statements then average the sum

    You wont need IF and AND for that. AVERAGEIFS is your friend here.

    For example:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See yellow cells in the attached.

    BSB
    Attached Files Attached Files
    Last edited by BadlySpelledBuoy; 06-30-2016 at 06:20 AM.

  3. #3
    Registered User
    Join Date
    01-29-2015
    Location
    Wigan, England
    MS-Off Ver
    7
    Posts
    10

    Re: IF and AND statements then average the sum

    Many thanks for your quick reply - I'll try it now and let you know how I get on!

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: IF and AND statements then average the sum

    I've added an example workbook above now to demonstrate it.
    Should be easy enough to port over to your real workbook but shout if you need more help.

    BSB

  5. #5
    Registered User
    Join Date
    01-29-2015
    Location
    Wigan, England
    MS-Off Ver
    7
    Posts
    10

    Re: IF and AND statements then average the sum

    I can't get it to work when I use it on my actual spreadsheet as it's returning a #DIV/0 error. I've amended the formula to take into account that the ranges start at row 16 and go through to row 2000 - will this cause the error?

    =AVERAGEIFS($AB16:$AB2000,$I16:$I2000,$AE$5,$J16:$J2000,$AF$4)

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: IF and AND statements then average the sum

    A #DIV/0 error means the result would be dividing 0 by 0, which is of course mathematically impossible.

    Filter the data so column I equals the value in AE5 and column J equals the value in AF4. Would the sum of column AB = 0 in that scenario?

    BSB

  7. #7
    Registered User
    Join Date
    01-29-2015
    Location
    Wigan, England
    MS-Off Ver
    7
    Posts
    10

    Re: IF and AND statements then average the sum

    I've applied the filters and despite there being data in column AB, the SUM does in fact = 0. The format of the cells in AB is Time, is this causing the issue?

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: IF and AND statements then average the sum

    The issue is purely that the answer is zero.

    What the formula is doing is summing the values in AB for all rows with the same value as AE5 in column I and the same value as AF4 in column J. Then dividing that number by the number of rows those two conditions are met on. Although there are rows that meet those criteria, the sum of AB for those row is zero and you cannot divide that.

    Amend the formula to:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This will simply show a zero in these scenarios, rather than the DIV error.

    Or swap ,0) at the end for ,"") if you'd rather the cell stayed blank.

    BSB
    Last edited by BadlySpelledBuoy; 06-30-2016 at 07:24 AM.

  9. #9
    Registered User
    Join Date
    01-29-2015
    Location
    Wigan, England
    MS-Off Ver
    7
    Posts
    10

    Re: IF and AND statements then average the sum

    I understand what you're saying, but even when I try to just add up the times in column AB as a simple =SUM() the answer is still 0 despite there being plenty of data in the column.

  10. #10
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: IF and AND statements then average the sum

    Are the times stored as text by any chance?

    Could we see a small (desensitized) sample workbook?

    BSB

  11. #11
    Registered User
    Join Date
    01-29-2015
    Location
    Wigan, England
    MS-Off Ver
    7
    Posts
    10

    Re: IF and AND statements then average the sum

    Despite the formatting of the cells saying that they were 'Time' it appears that yes indeed, the times were stored as text. I've resolved this by doing the following:

    Highlight the range of text to be converted.
    Go to Data, Text to Columns.
    Click Finish. The numbers are no longer considered numbers stored as text.

    Thank you for your help today, its greatly appreciated.

  12. #12
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: IF and AND statements then average the sum

    Happy to help

    BSB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Average of ranges marked by TRUE and FALSE statements
    By B_P in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-18-2014, 03:34 PM
  2. HELP!!! Using Multiple IF Statements...then coming up with an average.
    By jgsuf in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-22-2014, 04:39 PM
  3. [SOLVED] AVERAGE of cells using IF statements
    By KelleyD in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-02-2012, 11:14 PM
  4. [SOLVED] Weighted average with if statements as values
    By berger328 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-12-2012, 09:17 PM
  5. Excel 2007 : Average formulas of cells with IF statements in
    By Monkeychops08 in forum Excel General
    Replies: 4
    Last Post: 04-07-2011, 10:05 AM
  6. average, min, max combined with if statements
    By kevmac27 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-29-2008, 06:04 PM
  7. average with if and AND statements
    By Tim in forum Excel General
    Replies: 5
    Last Post: 10-02-2005, 09:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1