+ Reply to Thread
Results 1 to 20 of 20

Summing based on multiple conditions

  1. #1
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Summing based on multiple conditions

    I have been trying to search an array and cannot find the correct combination of functions to get the information I want. I might need a macro to do this but I will try anything. Here is an example:

    1 A 1
    1 B 2
    2 A 3
    2 B 4
    3 A 5
    3 B 6

    I want to search for 3 and A and return the value in the 3rd column. I have tried several functions but cant figure out how to make sure I get the correct value in the 2nd column that corresponds to the value in the 1st column.

    Thank for your help.
    Last edited by confu5ion; 02-11-2010 at 11:02 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula or Macro

    Try:

    =Sumproduct(--(A1:A100=3),--(B1:B100="A"),C1:C100)

    you can replace 3 and "A" with cell references containing those 2 items.

    also, adjust ranges to suit.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on multiple conditions

    Please note: I changed your title for you as it did not conform to our Forum Rules... please remember to do be more specific in the title next time.

  4. #4
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Excel Formula or Macro

    Maybe that example wasn't the best one.
    Part # Price Secondary # Price
    158A 1445.5 A 25.25
    158A 1445.5 B 0
    158A 1445.5 C 25.25
    158A 1445.5 D 25.25
    158A 1445.5

    167 1201 A 0
    167 1201 B 50.5
    167 1201 C 50.5

    310 935.25 B 0
    310 935.25 C 97

    I want to find the price of 167B1. Thanks.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on multiple conditions

    Which one is supposed to match that code?

  6. #6
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Excel Formula or Macro

    sorry I meant 167B.

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on multiple conditions

    So are we adding the price of 167 and price of B in same line?

    e.g.

    =Sumif(A1:A100,167,B1:B100)+Sumproduct(--(A1:A100=167),--(C1:C100="B"),D1:D100)

  8. #8
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Excel Formula or Macro

    We're close but it's giving me the wrong price. I am $1 off it gives me a price of $1252.5.

  9. #9
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Excel Formula or Macro

    Got it! Thanks.

  10. #10
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Summing based on multiple conditions

    Quote Originally Posted by NBVC View Post
    So are we adding the price of 167 and price of B in same line?

    e.g.

    =Sumif(A1:A100,167,B1:B100)+Sumproduct(--(A1:A100=167),--(C1:C100="B"),D1:D100)
    How would I use this same formula if I was looking for a text result instead of a price?

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on multiple conditions

    Example please...

  12. #12
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Summing based on multiple conditions

    158A good A small
    158A better B medium
    158A best C large
    167 better A large
    167 good B small
    167 best C medium

    Hopefully this helps. 167B would say good in one cell and small in another.

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on multiple conditions

    =Index(B$2:B$10,Match(1,($A$1:$A$10=167)*($C$1:$C$10="B"),0),0)

    and

    =Index(D$2:D$10,Match(1,($A$1:$A$10=167)*($C$1:$C$10="B"),0),0)

    adjust ranges to suit....

  14. #14
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Summing based on multiple conditions

    The formula equals what it should but I get NA error in the cell.

  15. #15
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on multiple conditions

    Maybe your column A is text:

    Try:

    =Index(B$2:B$10,Match(1,($A$1:$A$10="167")*($C$1:$C$10="B"),0),0)

    and

    =Index(D$2:D$10,Match(1,($A$1:$A$10=167)*($C$1:$C$10="B"),0),0)

  16. #16
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Summing based on multiple conditions

    #N/A #N/A
    158a good a small
    158a better b medium
    158a best c large
    167 better a large
    167 good b small
    167 best c medium
    Still no good.

  17. #17
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on multiple conditions

    Post the actual spreadsheet please!

  18. #18
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Summing based on multiple conditions

    Here is the file.
    Attached Files Attached Files

  19. #19
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on multiple conditions

    My bad... I forgot a function in there:

    =INDEX(B$2:B$10,MATCH(1,INDEX(($A$1:$A$10=167)*($C$1:$C$10="B"),0),0))

    and

    =INDEX(D$2:D$10,MATCH(1,INDEX(($A$1:$A$10=167)*($C$1:$C$10="B"),0),0))

  20. #20
    Registered User
    Join Date
    02-11-2010
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Summing based on multiple conditions

    Thank you very much for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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