+ Reply to Thread
Results 1 to 11 of 11

SUMIF but need to count rather than sum

  1. #1
    Registered User
    Join Date
    07-30-2008
    Location
    uk
    Posts
    18

    SUMIF but need to count rather than sum

    Hi,

    Can anyone helpt with this please. I cannot seem to find a count function that will work the same as a sumif but counting the entries rather than summing them.

    For example

    Column A list of product types sold
    Column B the value of products sold

    Sumif will look at column B and find any value that has the same product type in column A and add them up. I need to do the same but counting them instead.

    Any help much appreaciated.

    Pat

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

    Re: SUMIF but need to count rather than sum

    Assuming you want to count all instances of a Product as listed in A see COUNTIF.

  3. #3
    Registered User
    Join Date
    07-30-2008
    Location
    uk
    Posts
    18

    Re: SUMIF but need to count rather than sum

    Hi. The countif works differenty to the sumif function - I need the exact same function of sumif but counting rather than adding up.

    If I give a better example of what I need perhaps

    A B
    Client 1 10
    Client 2 5
    Client 1 15
    Client 3 6
    Clinet 1 20
    Client 4 2
    Client 4 5

    Sum if would tell me Client 1 spent 45, the sum of all values in column B where column A was equal to client 1.

    I want the formula that tells me that the number of times Client 1 ordered was in this example 3.

    I dont think countif achieves this

    ?

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

    Re: SUMIF but need to count rather than sum

    Quote Originally Posted by pat brown
    The countif works differenty to the sumif function
    Correct, it does what you want.

    Quote Originally Posted by pat brown
    I want the formula that tells me that the number of times Client 1 ordered was in this example 3.

    I dont think countif achieves this
    =COUNTIF(A:A,"Client 1")

  5. #5
    Registered User
    Join Date
    07-30-2008
    Location
    uk
    Posts
    18

    Re: SUMIF but need to count rather than sum

    Thanks DonkeyOte but this still doesnt solve the problem.

    Using my example, the table I want the results in will be similar to one with the data in although one line for each client number. It will expand right for each weeks product sales, so

    A B C
    Client 1 10 12
    Client 2 5 2
    Client 1 15 -
    Client 3 6 5
    Clinet 1 20 30
    Client 4 2 4
    Client 4 5 1

    So the count function I am looking for will list Clients' 1-4 in column A (but only once) with colum B showing the number of orders sold in week 1 and in C number sold for week 2 and so on, so the result table will look something like

    A B C
    Client 1 3 2 (as the third line down in my example did not have an order in week 2)
    Client 2
    Client 3
    Client 4

    I know this is hard to read as doesnt show in columns - not sure if I can attach an example spreadsheet to show you more clearly?

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: SUMIF but need to count rather than sum

    pivot table!
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

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

    Re: SUMIF but need to count rather than sum

    As Martin stated a Pivot might work here (how straightforward that would be will depend on whether "-" is text or 0)

    To attach a file use the paperclip icon in the reply dialog - if you can't see it click GoAdvanced and proceed from there.

    In the sample specify desired results (and where you want results returned)

    Please also specify the XL version in use ... in cases such as these the more recent versions (ie XL2007 onwards) offer quite a few alternatives to their predecessors.

  8. #8
    Registered User
    Join Date
    04-01-2006
    Posts
    23

    Re: SUMIF but need to count rather than sum

    Quote Originally Posted by pat brown View Post
    Thanks DonkeyOte but this still doesnt solve the problem.

    Using my example, the table I want the results in will be similar to one with the data in although one line for each client number. It will expand right for each weeks product sales, so

    A B C
    Client 1 10 12
    Client 2 5 2
    Client 1 15 -
    Client 3 6 5
    Clinet 1 20 30
    Client 4 2 4
    Client 4 5 1

    So the count function I am looking for will list Clients' 1-4 in column A (but only once) with colum B showing the number of orders sold in week 1 and in C number sold for week 2 and so on, so the result table will look something like

    A B C
    Client 1 3 2 (as the third line down in my example did not have an order in week 2)
    Client 2
    Client 3
    Client 4

    I know this is hard to read as doesnt show in columns - not sure if I can attach an example spreadsheet to show you more clearly?
    Hi,

    Assuming titles in Row 1, data in rows 2:13 then

    in (say) Cell B20

    =CountIf(A$2:A$13,"Client "&Row()-19) will count the occurances that match the said client

    This first fomula can be duplicated downwards and will reflect the count for the items in the rows concerned (hence Client 1 in the first Row, client 4 in the 4th.

    and in (say) cell C20

    =Sumproduct(--($A$2:$A$13="Client "&Row()-19),(--(C$2:C$13<>"")))

    can be used on Row 20 (cell C20) and then Formula copied rightwards and downwards etc.

    Regards

    DunnyDoor

  9. #9
    Registered User
    Join Date
    07-30-2008
    Location
    uk
    Posts
    18

    Re: SUMIF but need to count rather than sum

    Thanks guys. The data that will be driving the result will constantly change and be added to in both rows and columns for each particular week.

    Attached is a spreadsheet with the base data, the data with SUMIF and underneath that the result that I want to find formula for, which is basically exactly the same as SUMIF but rather than adding values, returning the number of entries.

    I am using Excel 2007

    Hope this helps and thanks in advance.

    Pat
    Attached Files Attached Files

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

    Re: SUMIF but need to count rather than sum

    Per your sample file (and use of XL2007)

    C31: =COUNTIFS($B$5:$B$15,$A31,C$5:C$15,">0")
    applied across results matrix

  11. #11
    Registered User
    Join Date
    07-30-2008
    Location
    uk
    Posts
    18

    Re: SUMIF but need to count rather than sum

    DonkeyOte

    The COUNTIFS function has solved this question.

    Thankyou to all for the input. Will mark this as solved now.

    Pat

+ 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