+ Reply to Thread
Results 1 to 16 of 16

Returning desired number on conditions

  1. #1
    Registered User
    Join Date
    07-05-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2010
    Posts
    57

    Returning desired number on conditions

    Hello,

    So say I have 3 columns:

    I need to match the 3 digit code in the left most column, then if that matches, match another one digit code. Then if that matches, sum up the number/quantity of whatever situations meet those conditions. I'm sorry this is kind of confusing but any help would be greatly appreciated!

    Thanks!

    Rob

    For Example heres a sample dataset

    213 3 1,120
    321 3 1,020
    213 3 2,345
    223 2 3,409
    213 1 1,111

    So for one i would like to match all of those that have the 213 code as well as the code "3", then sum up those two numbers to the right.... Thanks!

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Returning desired number on conditions

    Hi Montoro22,

    then sum up those two numbers to the right.
    What would be the result ?
    Also it would be helpful if you can upload a sample workbook. thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    07-05-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Returning desired number on conditions

    basically from the example i put in the original post. I want it to match the 213 and if that matches, match the 3, and if that matches sum up the numbers in the last column. So in this instance sum up 1,120 and 2,345. So I am looking for it to return the total of 3,455

  4. #4
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Returning desired number on conditions

    Assuming your data is arranged in columns A:C (for simplicity's sake let's say A1:C100).

    Place the number you'd like to check for column A (213) in cell D1 and the number for column B (3) in E1.

    Your formula will be:

    =SUMPRODUCT(--(A1:A100=D1),--(B1:B100=E1),(C1:C100))

  5. #5
    Registered User
    Join Date
    07-05-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Returning desired number on conditions

    Okay so here is part of the actual spreadsheet.

    So I need to match the 3 digit code on the left (column A), then match a certain number in column E. And if those two specifications meet, sum up column P

    Any ideas? the last one didn't work Ben, thanks tho
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Returning desired number on conditions

    Using Ben's approach (which does work), Let's put the value in A to match in A16, the value in E in B16 (this cell needs to be formatted as text because column E is formatted as text)

    =SUMPRODUCT(--($A$1:$A$13=A16), --($E$1:$E$13=B16),P1:P13)
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Returning desired number on conditions

    When you say "Match up", do you mean you want to choose one and get the total for it? Or have a list of all the combinations of column A and E with their totals?

    Also, it looks like column P is just 0s and 1s - so you're not really looking for a total; you're just adding a third condition - that column P must equal 1.

    Can you clarify please?

  8. #8
    Registered User
    Join Date
    07-05-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Returning desired number on conditions

    Sorry yeah I need the total of column p for all of those that match the first two criterias.

    And Chemist it seems to be pulling put it keeps on returning 0, I need the sum of column p for those rows that meet the criteria.

    Thanks again

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Returning desired number on conditions

    Did you format B16 as text before you entered your value? If not, that's why you're getting 0

  10. #10
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Returning desired number on conditions

    Quote Originally Posted by Montoro22 View Post
    Sorry yeah I need the total of column p for all of those that match the first two criterias.

    And Chemist it seems to be pulling put it keeps on returning 0, I need the sum of column p for those rows that meet the criteria.

    Thanks again
    What are the criteria? Can you post them please?

  11. #11
    Registered User
    Join Date
    07-05-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Returning desired number on conditions

    by criteria i mean match column a and then column e

    And Chemist B it works good, I just have another question.

    Is it possible to match say 2 numbers in column e, so for instance it will take both "2" and "B"?

  12. #12
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Returning desired number on conditions

    Match column A and column E TO WHAT for god's sake? omg ... unless I'm really being dense here...

  13. #13
    Registered User
    Join Date
    07-05-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Returning desired number on conditions

    To each unque code in column A and to one of the 7 one digit codes in column E.... As I keep saying, I'm pulling all the data based on the 3 digit codes and the one digit code. If you look at the initial post you can clearly see.

  14. #14
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Returning desired number on conditions

    So again, as I asked before, do you want a list of all the combinations of column A and E, with their respective totals?

    ---------- Post added at 02:09 PM ---------- Previous post was at 02:06 PM ----------

    Quote Originally Posted by Montoro22 View Post
    by criteria i mean match column a and then column e

    And Chemist B it works good, I just have another question.

    Is it possible to match say 2 numbers in column e, so for instance it will take both "2" and "B"?
    If you put the third condition in C16, for example, try

    =SUMPRODUCT(--($A$1:$A$13=A16),(($E$1:$E$13=B16)+($E$1:$E$13=C16)),P1:P13)

  15. #15
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Returning desired number on conditions

    =sumproduct(--($a$1:$a$13=a16), ($a$1:$a$13=a16)+($e$1:$e$13="b"),p1:p13)

  16. #16
    Registered User
    Join Date
    07-05-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Returning desired number on conditions

    Thanks ChemistB works perfectly, thanks for the help I appreciate it.

    ---------- Post added at 02:25 PM ---------- Previous post was at 02:23 PM ----------

    Thanks Chemist works perfectly thanks for all the help! It's much appreciated

+ 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