+ Reply to Thread
Results 1 to 9 of 9

multiple criterias in SUMIF formula

  1. #1
    Registered User
    Join Date
    05-26-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    27

    multiple criterias in SUMIF formula

    hi all,

    is there any way for a sumif formula to have multiple criterias? for my case, after the formula checks for a condition, it has to check for another condition before summing up the figures.

    this is my current formula:

    Please Login or Register  to view this content.
    E2 contains a certain id and the formula will total up the figures in column F for that particular id. i want to add another condition that the formula has to check for another condition before summing up. it has to check the description in column C for these words 'OR'. only after that it can total up for the id AND with the words 'OR'.

    i want to be able to use wildcards for 'OR' since the descriptions might contain 'AW OR', 'OR (ST)' etc.

    how do i add the other condition into the formula? pls help.
    Last edited by aysrun; 07-29-2009 at 02:40 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: multiple criterias in SUMIF formula

    SUMIF can only have one condition... pre XL2007 you're looking at SUMPRODUCT to do multiple tests (in XL2007 SUMIFS was introduced) ...

    =SUMPRODUCT(--($A$1:$A$1000=$E2),--ISNUMBER(SEARCH(" OR "," "&$C$1:$C$1000&" ")),$F$1:$F$1000)

    NOTE: you can not use entire column references in Sumproduct (pre XL2007) and you should ensure you keep ranges to a minimum to avoid performance issues.

    On an aside you can also use Concatentation to create one unique identifier thereby negating need for Sumproduct / Array, eg:

    Z1: =$A1&":"&ISNUMBER(SEARCH(" OR "," "&$C1&" "))
    copied down for all rows

    Then SUMPRODUCT becomes a more efficient SUMIF

    =SUMIF(Z:Z,$E2&":TRUE",F:F)

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: multiple criterias in SUMIF formula

    =SUMPRODUCT((A2:A4=E2)*(ISNUMBER(SEARCH("or";C2:C4))*F2:F4))
    I suppose the condition is in col A
    Adapt the ranges to your needs ( ranges like A:A are not permitted), and eventually post a sample workbook if it does not work

  4. #4
    Registered User
    Join Date
    05-26-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: multiple criterias in SUMIF formula

    hi all. unfortunately mine is a very big file with thousands of data.

    i have attached a sample workbook.

    in Worksheet, E21 takes in the sum of the VOLUME found in REP09 based on the id from E2.
    i am now working on D9:D12 where i have to take in the total numbers from PERCENTAGES found in REP09 based on the id from E2 and the descriptions in
    B9:B12.

    they are supposed to total up for each desc, say for ON US, the formula should sum up VC ON US and MC ON US in REP09 based on the id.

    thanks in adv.
    Attached Files Attached Files
    Last edited by aysrun; 07-28-2009 at 04:45 AM.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: multiple criterias in SUMIF formula

    Based purely on your sample file:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-26-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: multiple criterias in SUMIF formula

    thanks DonkeyOte. the formula works just fine.

    problem is now, i have another column for a new condition. after getting the percentages based on the id and description, i have to look at a new column, column G and find out if the description match the codes 99.
    if the descriptions "MC ON US" and "VC ON US" match the codes 99 in column G, instead of dumping into cells E9, each have to be displayed in cells E13 and E14 according to the descriptions.

    based on the formula, how do i add the criteria to it?
    thanks in adv!!!
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: multiple criterias in SUMIF formula

    Hi Aysrun,
    do you think there are any more conditions or things you need to do ?
    If so please state them all at once.

    It will be much easier and less time consuming to find a solution to the global problem than having to begin anew each time .
    Don't forget all people here are volunteers and help you out on their spare time

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: multiple criterias in SUMIF formula

    thanks DonkeyOte. the formula works just fine.
    so may I ask why you're not using it in your latest file ?
    the formulae you're using in E9:E11 in your latest example are arguably less efficient, moreover you're not using absolute references which may lead to issues going forward, I would strongly advise implementing the formula previously provided.

    problem is now, i have another column for a new condition. after getting the percentages based on the id and description, i have to look at a new column, column G and find out if the description match the codes 99.
    if the descriptions "MC ON US" and "VC ON US" match the codes 99 in column G, instead of dumping into cells E9, each have to be displayed in cells E13 and E14 according to the descriptions.
    based on the original formula provided, revised with additional test highlighted in red for your convenience:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-26-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: multiple criterias in SUMIF formula

    Quote Originally Posted by DonkeyOte View Post
    the formulae you're using in E9:E11 in your latest example are arguably less efficient, moreover you're not using absolute references which may lead to issues going forward, I would strongly advise implementing the formula previously provided.
    the formulae was just a tryout. will use yours.

    and the formulae with the criteria for column G works. thanks.

+ 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