+ Reply to Thread
Results 1 to 6 of 6

Same formula returns 0 in some cells, works correctly in others

  1. #1
    Registered User
    Join Date
    07-09-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    3

    Same formula returns 0 in some cells, works correctly in others

    I am confused as to why this is happening. I am using the following formula:

    =AVERAGE(SMALL($C$2:$C$23,{1,2,3,4,5})*($A$2:$A$23=$E$2))

    The purpose of this is to return the average of the lowest 5 times of the "Blue" team. The problem with this is that it only works on rows that "Blue" on it. This is a problem for me going forward with formatting the layout of my work. What do I need to do for the position of the formula cell to be irrelevant to it working correctly?

    Picture is attached, thank you
    Attached Images Attached Images

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Same formula returns 0 in some cells, works correctly in others

    Here are 2 approaches:

    This ARRAY FORMULA, completed by holding down CTRL and SHIFT when you press ENTER (instead of just pressing ENTER)
    returns the average of the 5 lowest Col_C values where the corresponding Col_A value matches E2
    Please Login or Register  to view this content.
    ...and this regular (but longer) formula does the same thing (without needing CTRL+SHIFT+ENTER)
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    07-09-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    3

    Re: Same formula returns 0 in some cells, works correctly in others

    Ron,

    That works like a champ, thank you

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Same formula returns 0 in some cells, works correctly in others

    Glad you got something you can use!

    If that resolves your issue, please take a moment to mark this thread as SOLVED (from the Thread Tools menu)

  5. #5
    Registered User
    Join Date
    07-09-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    3

    Re: Same formula returns 0 in some cells, works correctly in others

    Ok I thought it had worked but upon further inspection, some is off. If you look at the attached picture, the equations use returned top 3 and top 5 averages that are higher than the Top 1 value which is impossible. The equations used are as follows:

    Top1: =MAX(IF(($L$2:$L$34=$N$4),$K$2:$K$34))
    Top3: =AVERAGE(LARGE(INDEX(($L$2:$L$23<>$N$4)*$K$2:$K$23,0),{1,2,3}))
    Top5: =AVERAGE(LARGE(INDEX(($L$2:$L$23<>$N$4)*$K$2:$K$23,0),{1,2,3,4,5}))

    The "TRUE" results are what I manually selected and calculated so they would be correct.

    (The MIN version which I asked about in the OP is exhibiting the same behavior)

    Edit: I see that the MAX formula uses an "=" condition and the AVERAGE formulas use a "<>" condition It appears that is the issue. What would the "<>" be useful for?

    Excel2.png
    Last edited by BoHeck; 07-15-2015 at 04:04 PM.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Same formula returns 0 in some cells, works correctly in others

    1st, not all members can see png pics in here, plus, we cannot work with pics anyway

    2nd "<>" means "not equal to"

    3rd, note that those are ARRAY formulas...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    (I suspect that 3 above, is probably your problem)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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. Replies: 7
    Last Post: 03-28-2014, 07:56 AM
  2. excel 2007 formula works great but when open in 2010 returns##
    By lizsantiago07 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-25-2013, 09:25 PM
  3. [SOLVED] Formula works but returns N/A
    By troysie in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-10-2013, 11:00 AM
  4. One Sumproduct Formula works - while other returns #VALUE!?
    By Correna in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-04-2006, 09:10 AM
  5. [SOLVED] formula returns (correctly) a negative value
    By brit64 in forum Excel General
    Replies: 5
    Last Post: 09-19-2005, 04:06 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