+ Reply to Thread
Results 1 to 14 of 14

COUNTIF - multiple criteria (excel 2003)

  1. #1
    Registered User
    Join Date
    10-15-2013
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    15

    COUNTIF - multiple criteria (excel 2003)

    Hi All,

    I tried to do countif for multiple criteria, but since I am on 2003, I do not have countifs

    Tried this formula, but it generated incorrect result. It should only count the occurrences of the output that match all the IF criteria

    =SUMPRODUCT(--(IF(((Database!$B$2:$B$14=$B$7)+($B$7=""))*((Database!$X$2:$X$14=$B$9)+($B$9=""))*((Database!$C$2:$C$14>=$B$6)+($B$6=""))*((Database!$C$2:$C$14<=$C$6)+($C$6=""))*((Database!$E$2:$E$14=$B$10)+($B$10=""))*((Database!$G$2:$G$14>=$B$11)+($B$11=""))*((Database!$H$2:$H$14=$B$12)+($B$12=""))*((Database!$J$2:$J$14>=$B$13)+($B$13=""))*((Database!$L$2:$L$14=$B$14)+($B$14=""))*((Database!$M$2:$M$14>=$B$15)+($B$15=""))*((Database!$M$2:$M$14<=$C$15)+($C$15=""))*((Database!$D$2:$D$14=$B$16)+($B$16=""))*((Database!$S$2:$S$14=$B$17)+($B$17=""))*(Database!$Z$2:$Z$14=$A$21),Database!$P$2:$P$14))

    Hope for your advice.

    Thank you!

    Rgds,
    Nat

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: COUNTIF - multiple criteria (excel 2003)

    If with Multiple range in Sumproduct won’t get the right results…

    Replace the SUMPRODUCT with SUM and enter it as array formula…

    Array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: COUNTIF - multiple criteria (excel 2003)

    Hi,

    First of all, it's very unlikely that the use of the IF in there is necessary (or even correct).

    Secondly, can you explain in words what each of the typical bracketed criteria is trying to achieve? For example, a construction such as:

    ((Database!$B$2:$B$14=$B$7)+($B$7=""))

    which seems to make up the majority of your conditions, is logically quite unusual, and in all probability incorrect, since the second part ($B$7=""), which is either TRUE or FALSE, will be added to the array of returns from the first part (Database!$B$2:$B$14=$B$7) and so could produce returns greater than 1. For example, if Database!$B$2:$B$14 contains

    {7;1;5;(blank);6;10;6;(blank);2;4;(blank);10;9}

    and $B$7 is blank, then:

    ((Database!$B$2:$B$14=$B$7)+($B$7=""))

    will equate to:

    ({FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE}+TRUE)

    which is:

    {1;1;1;2;1;1;1;2;1;1;2;1;1}

    which may not be at all what you want.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: COUNTIF - multiple criteria (excel 2003)

    Me too thought to raise question about this approach ((Database!$B$2:$B$14=$B$7)+($B$7="")) but left that part by saying myself + operates as OR condition in Array Formulas…

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: COUNTIF - multiple criteria (excel 2003)

    "+ operates as OR condition in Array Formulas…"

    Only if the two parts are mutually exclusive (and of the same size).

    Here, for example, it's quite possible that Database!$B$2:$B$14=$B$7 AND $B$7="" are BOTH true, in which case the "+" is not having the (desired) effect of acting as an OR operator.

    Regards

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: COUNTIF - multiple criteria (excel 2003)

    @ XOR LX,

    Thanks for the info...

    I would like to share a scenario with you for getting better understanding on this…

    We will test this with two sheets Database sheet and Current Sheet

    In Database sheet just leave B6 & B8 as blank and in B7 type abc
    In Current Sheet – Put the below formula and leave the B7 cell as blank

    As you are aware it is array formula…
    =SUM(IF((Database!$B$6:$B$8=$B$7)+($B$7=""),1,0))

    It will get the count of 3. But in data base sheet Two cells only blank so the result should be 2. But its treating the next B7 with or condition and checking that too even though it is not in equal size and getting the count of 3.

    Please suggest and correct me if my understanding is wrong…

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: COUNTIF - multiple criteria (excel 2003)

    Perhaps, but you've artificially changed the scenario to return 1s in the case of a TRUE, and in any case I don't think the example you give is applicable generally.

    Change it to (as in the OP's example):

    =SUMPRODUCT((Database!$B$6:$B$8=$B$7)+($B$7=""))

    and see what you get.

    Regards

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: COUNTIF - multiple criteria (excel 2003)

    Yes… wantedly I made it in that way to prove the real array formula will treat the + as OR operator lol

    In your example the Sumproduct condition is adding the Or condition result to each result and getting the 6 as result like True;True;True+True = True+True;True+True;True+True.

    But we are aware Sumproduct and IF with array both will act in a different way instead doing performing the same terminology…

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: COUNTIF - multiple criteria (excel 2003)

    "But we are aware Sumproduct and IF with array both will act in a different way instead doing performing the same terminology…"

    Not really in this case. Remember, you arbitrarily added in a return of 1 for the TRUE condition. The actual array replica of that SUMPRODUCT formula would be:

    =SUM((Database!$B$6:$B$8=$B$7)+($B$7=""))

    which again, in your example would give 5.

    But I know what you mean!

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: COUNTIF - multiple criteria (excel 2003)

    But I know what you mean!
    Hm… I got your point….

    But in OP’s example he used If with Sumproduct combination and I converted it as If with Sum combination as an array and in this case the + will operate as Or only…

    So both of us won lets rep each other lol

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: COUNTIF - multiple criteria (excel 2003)

    "lets rep each other lol"

    Have done!!

    (Don't tell the Moderators though or they'll suspect us of some mutual repping collusion! )

  12. #12
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: COUNTIF - multiple criteria (excel 2003)

    Me too did it

    Ha ha ha already they are in the job of moderating each threads lol

  13. #13
    Registered User
    Join Date
    10-15-2013
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: COUNTIF - multiple criteria (excel 2003)

    Hi All, Thanks for responding to my thread! Appreciate your help & Advice

    I am pretty new in excel functions, so I am still having some confusion with the 'COUNTIFS' equivalent function for excel 2003.

    Perhaps to make the context clearer, I have created the sample worksheet for this problem
    A1:C11 - Input Segment - User can specify the criteria to generate historical price result within database
    A13:D29 - Output Segment (Summary) - Provides summary of the results based on specified criteria. Divided into 2 sub-segments, i.e. existing client & new client, which are further broken down by 'rating' (existing) or 'debt indicator rage' (new).
    There are 2 types of price data: i) Advisory Fee, ii) Margin & 2 types of calculation output: i) Average [SOLVED], ii) No of Deals (Count the number of occurrences for defined criteria)[NOT SOLVED]
    A31:F61 - Output Segment (Detail) - Provides details of the data within the database as specified by the criteria. Ideally there is sorting function to sort out results based on specified category [NOT SOLVED]

    Currently, I am unable to figure out formula for "No of Deals" & also if there is a function from excel to be able to pull out the individual data automatically & arranged it as per output range A31:F61 more instantaneously

    Sorry for throwing many questions & thanks for helping on this

    Cheers,
    Nat
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    10-15-2013
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: COUNTIF - multiple criteria (excel 2003)

    Hi all, my issues was resolved by using the formula =COUNT(IF(...............)) for the issue ii) no of deals. Thanks for all your help.

+ 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. Countif, Multiple Criteria, Multiple Sheets, Excel 2003
    By shyammankoo in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-07-2013, 06:50 AM
  2. Multiple COUNTIF - Excel 2003
    By db1966 in forum Excel General
    Replies: 5
    Last Post: 02-09-2012, 09:50 AM
  3. Multiple Countif Statement for Excel 2003
    By Mile029 in forum Excel General
    Replies: 2
    Last Post: 11-30-2011, 02:58 PM
  4. Replies: 2
    Last Post: 02-25-2011, 09:42 AM
  5. Excel 2003: COUNTIF/SUMPRODUCT, Multiple Criteria w/Wildcard
    By EricF in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-24-2008, 09:41 PM

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