+ Reply to Thread
Results 1 to 13 of 13

Average array, 1 row condition, 2 column conditions

  1. #1
    Registered User
    Join Date
    05-10-2016
    Location
    Geneva
    MS-Off Ver
    2010 Professional
    Posts
    6

    Average array, 1 row condition, 2 column conditions

    Hi all,

    I would like a formula which calculates the average according to three conditions.

    As an example, this is what the data looks like (I couldn't attach the excel file for some reason)

    Please Login or Register  to view this content.

    In this case, I'd like to average according to the conditions;
    -Asia
    -One
    -Small

    Does anyone know how to do this? I actual dataset is much bigger so an automatic way of doing this is what I'm after.

    Thanks

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Average array, 1 row condition, 2 column conditions

    please attach a sample excel file
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Registered User
    Join Date
    05-10-2016
    Location
    Geneva
    MS-Off Ver
    2010 Professional
    Posts
    6

    Re: Average array, 1 row condition, 2 column conditions

    Hi, thanks for replying.

    However, I don't see an attachment in your post..

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Average array, 1 row condition, 2 column conditions

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window (or use the paperclip icon).
    Cheers!
    Deep Dave

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Average array, 1 row condition, 2 column conditions

    One way ...

    =SUMPRODUCT(($B$2:$E$7)*($A$2:$A$7="Asia")*($B$1:$E$1="One Small"))/SUMPRODUCT(($A$2:$A$7="Asia")*($B$1:$E$1="One Small"))

    Better if you put the criteria is separate celLs

    =SUMPRODUCT(($B$2:$E$7)*($A$2:$A$7=M1)*($B$1:$E$1=N1))/SUMPRODUCT(($A$2:$A$7=M1)*($B$1:$E$1=N1))


    M1 ="Asia"

    N1 ="One small"
    Attached Files Attached Files
    Last edited by JohnTopley; 05-10-2016 at 07:06 AM.

  6. #6
    Registered User
    Join Date
    05-10-2016
    Location
    Geneva
    MS-Off Ver
    2010 Professional
    Posts
    6

    Re: Average array, 1 row condition, 2 column conditions

    OK - so I hope the excel file is attached with a before and an after tab - is it clearer now?
    Attached Files Attached Files

  7. #7
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Average array, 1 row condition, 2 column conditions

    Put this in C4 of the After sheet

    =INDEX(Before!$C$5:$F$10,MATCH(C$3,Before!$B$5:$B$10,0),MATCH(1,($B4=Before!$C$3:$F$3)*($A4=Before!$C$4:$F$4),0))

    Drag down and across

    ...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.
    Attached Files Attached Files
    Last edited by NeedForExcel; 05-10-2016 at 06:04 AM.

  8. #8
    Registered User
    Join Date
    05-10-2016
    Location
    Geneva
    MS-Off Ver
    2010 Professional
    Posts
    6

    Re: Average array, 1 row condition, 2 column conditions

    Hi NeedForExcel,

    Thanks for your reply. I got the formula you provided working, but it picks one cell value.

    What I would like is the average of all the cells which meet the three predefined conditions.

    Thanks

  9. #9
    Registered User
    Join Date
    05-10-2016
    Location
    Geneva
    MS-Off Ver
    2010 Professional
    Posts
    6

    Re: Average array, 1 row condition, 2 column conditions

    To clarify, in the case of Asia-Pacific, it appears twice in the "Before" tab. Therefore the output should be an average of where ever "Asia-Pacific", "One" and "Small" occur.

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Average array, 1 row condition, 2 column conditions

    See attached: why make life difficult using two columns/rows when one would do?

    =SUMPRODUCT((Before!$C$5:$F$10)*(Before!$B$5:$B$10=After!C$3)*(Before!$C$4:$F$4=After!$B4))/SUMPRODUCT((Before!$B$5:$B$10=After!C$3)*(Before!$C$4:$F$4=After!$B4))
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,911

    Re: Average array, 1 row condition, 2 column conditions

    Try this in cell C4:

    =AVERAGE(IF(C$3=Before!$B$5:$B$10,OFFSET(Before!$B$5:$B$10,0,MATCH($B4&$A4,Before!$C$3:$F$3&Before!$C$4:$F$4,0)),""))

    Enter with Ctrl+Shift+Enter

    Copy across and down

  12. #12
    Registered User
    Join Date
    05-10-2016
    Location
    Geneva
    MS-Off Ver
    2010 Professional
    Posts
    6

    Re: Average array, 1 row condition, 2 column conditions

    Phuocam, it works!!!!! THANKS SO MUCH!


  13. #13
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,911

    Re: Average array, 1 row condition, 2 column conditions

    You're welcome.

+ 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: 3
    Last Post: 04-02-2016, 08:16 PM
  2. [SOLVED] 4 conditions in an Array Average
    By FivestarMac in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-15-2015, 03:55 PM
  3. get average of column based on conditions
    By rafnews in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-12-2014, 02:29 PM
  4. [SOLVED] Two Condition Array to Lookup Text in a Third Column
    By hurst2008 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-01-2014, 03:36 PM
  5. [SOLVED] sumproduct of multiple conditions, with 1 column with selective condition
    By melvyndb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2012, 04:55 AM
  6. average of array with condition
    By kghisla in forum Excel General
    Replies: 2
    Last Post: 10-10-2010, 03:11 PM
  7. Replies: 2
    Last Post: 10-08-2008, 08:39 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