+ Reply to Thread
Results 1 to 10 of 10

sum in matrix if conditions

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    sum in matrix if conditions

    Hi, I'm trying to sum (numeric) content of matrix if 1st colum is into a certain range.
    I was able to do it with letters (e.g. sum if 1st column is A or B) but not with numbers (e.g. sum if 1st column is between 10 and 17)

    I'm attaching the very simple file I'm working on..can you please help? table is on the right (then I also have a question for that on the left but I'll save it for later).

    Thanks!
    Attached Files Attached Files

  2. #2
    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
    30,878

    Re: sum in matrix if conditions

    Try

    =SUMIFS(H2:H9,G2:G9,">9",G2:G9,"<17")

    Range must be same dimensions so cannot have H2:I9

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,991

    Re: sum in matrix if conditions

    Try this:

    =SUMPRODUCT($H$2:$I$9*($G$2:$G$9>9)*($G$2:$G$9<17))

    This does not need C+S+E.

    Also, in E2 copied down:

    =SUMPRODUCT($B$2:$C$9*($A$2:$A$9=D2))
    Last edited by AliGW; 11-05-2017 at 12:01 PM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  4. #4
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    514

    Re: sum in matrix if conditions

    Try the following array formula (to be entered using Ctrl+Shift+Enter, not just Enter):

    =SUM(IF((G2:G9>9)*(G2:G9<17),H2:I9))

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,656

    Re: sum in matrix if conditions

    For the right table:

    =SUMPRODUCT(($G$2:$G$9>9)*($G$2:$G$9<17)*$H$2:$I$9)

    BTW, left one:
    E1=SUMPRODUCT((($A$2:$A$9="A")+($A$2:$A$9="B"))*$B$2:$C$9)
    E2=SUMPRODUCT(($A$2:$A$9="A")*$B$2:$C$9)
    E3=SUMPRODUCT(($A$2:$A$9="B")*$B$2:$C$9)
    Quang PT

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,991

    Re: sum in matrix if conditions

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  7. #7
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    Re: sum in matrix if conditions

    Quote Originally Posted by JohnTopley View Post
    Try

    =SUMIFS(H2:H9,G2:G9,">9",G2:G9,"<17")

    Range must be same dimensions so cannot have H2:I9
    mmh..that must be the reason why the formula can't work..so I can't use it mixing ranges vector / matrix

  8. #8
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    Re: sum in matrix if conditions

    Quote Originally Posted by Root_ View Post
    Try the following array formula (to be entered using Ctrl+Shift+Enter, not just Enter):

    =SUM(IF((G2:G9>9)*(G2:G9<17),H2:I9))
    This doesn't work, already tried!

  9. #9
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    Re: sum in matrix if conditions

    Quote Originally Posted by AliGW View Post
    Try this:

    =SUMPRODUCT($H$2:$I$9*($G$2:$G$9>9)*($G$2:$G$9<17))

    This does not need C+S+E.

    Also, in E2 copied down:

    =SUMPRODUCT($B$2:$C$9*($A$2:$A$9=D2))
    Well this worked I was missing that additional "multiply" which seemed to be the trick (or rule ^^).
    Thank you!

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,991

    Re: sum in matrix if conditions

    You're welcome!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. [SOLVED] Average of matrix elements using row and column conditions
    By Luis Ah-Hoy Jr. in forum Excel General
    Replies: 3
    Last Post: 06-09-2017, 10:42 AM
  2. Copy certain cells based on matrix conditions
    By etaver in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2017, 11:37 AM
  3. deleted post
    By joemac92 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-10-2015, 12:19 AM
  4. Multiple conditions with matrix table
    By redjess555 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-01-2015, 09:20 AM
  5. Filling matrix depending on conditions
    By sharpxs in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-05-2014, 06:06 AM
  6. Dynamic Comparitive Matrix Table with Data validation conditions
    By santhosh51 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-08-2013, 09:21 AM
  7. Replies: 1
    Last Post: 07-08-2013, 09:20 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