+ Reply to Thread
Results 1 to 5 of 5

AVERAGEIF with a twist..

  1. #1
    Registered User
    Join Date
    10-04-2015
    Location
    Madrid Spain
    MS-Off Ver
    2013
    Posts
    7

    AVERAGEIF with a twist..

    Hi all,

    I am looking to do an AVERAGEIF, but only for "x" number of the highest values within a range.

    Example:

    We have one tab with 3 columns:

    Office Name City Employees
    Clarendon DC 4
    Georgetown DC 5
    Horace Mann DC 6

    There are multiple offices within the same city.

    We have another tab with 3 columns:

    City Number of selected offices Avg number of employees for selected offices
    DC 2 ????

    As you can see, I am looking to compute the avg number of employees in an office for DC, but we are only taking the 2 offices with the highest number of employees.

    I canīt think of any conceivable way to do this. Can anyone help please?

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,231

    Re: AVERAGEIF with a twist..

    Is it always 2 offices that you want to use for the average?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: AVERAGEIF with a twist..

    @ Svilen could you post a workbook to make it more clear
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  4. #4
    Registered User
    Join Date
    10-04-2015
    Location
    Madrid Spain
    MS-Off Ver
    2013
    Posts
    7

    Re: AVERAGEIF with a twist..

    Quote Originally Posted by Glenn Kennedy View Post
    Is it always 2 offices that you want to use for the average?
    No, it is not. The number of offices varies in function of a different spreadsheet, which is irrelevant to this problems.
    The number of offices selected for the average will always be lower or equal to the number of total offices in the range.

    Quote Originally Posted by hemesh View Post
    @ Svilen could you post a workbook to make it more clear
    I will try to post a workbook a bit later today when things calm down in the office.

    Thanks!

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,231

    Re: AVERAGEIF with a twist..

    try this array formula:

    =SUMPRODUCT(LARGE(IF($B$2:$B$7=$E2,$C$2:$C$7),ROW(INDIRECT("1:"&$F2))))/$F2

    Array Formulae are a little different from ordinary formulas in that they MUST be 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 the outside of your formula. If you do not CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly braces yourself - it won't work...

    City names in B, values in C, selected city and number to average in E2 and F2. copy down if needed.
    Attached Files Attached Files

+ 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. Min If with a Twist
    By david0985 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-10-2014, 06:21 PM
  2. looking for duplicates with a twist
    By boymedia in forum Excel General
    Replies: 2
    Last Post: 03-29-2012, 07:27 PM
  3. #div/0! with a twist
    By Bjordion in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-11-2011, 03:53 PM
  4. Sum with a twist
    By ace4andy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-26-2008, 03:08 AM
  5. SumIf with a twist?
    By coldmejl in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-16-2006, 05:55 PM
  6. Sumif with a twist?
    By Aladin Akyurek in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 07:05 PM
  7. [SOLVED] Sumif with a twist?
    By Bruce in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  8. Sumif with a twist?
    By Bruce in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

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