+ Reply to Thread
Results 1 to 7 of 7

COUNT involving several columns

Hybrid View

  1. #1
    Registered User
    Join Date
    07-18-2008
    Location
    Australia
    Posts
    40

    COUNT involving several columns

    Hi, I need to find a formula on cell A2 on the attached file. The formula should show me the count of Customers who buy SKU 1 only.

    I tried to use filters across SKU (2-16) where there is "0" and then count all customers who have values >0 on Column B. But this takes a long time and I have to do similar tables quite a few times. I was just hoping if anyone can come up with a more efficient solution to it.

    Regards.
    Attached Files Attached Files
    Last edited by nsd3; 09-07-2009 at 10:04 PM.

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

    Re: COUNT involving several columns

    One route... create a key of 0/1 eg:

    T5:
    =SIGN(B5)&":"&SIGN(C5)&":"&SIGN(D5)&":"&SIGN(E5)&":"&SIGN(F5)&":"&SIGN(G5)&":"&SIGN(H5)&":"&SIGN(I5)&":"&SIGN(J5)&":"&SIGN(K5)&":"&SIGN(L5)&":"&SIGN(M5)&":"&SIGN(N5)&":"&SIGN(O5)&":"&SIGN(P5)&":"&SIGN(Q5)
    copy down for all rows
    Then you can use a simple and efficient COUNTIF... eg:

    B2:
    =COUNTIF($T$5:$T$100,SUBSTITUTE("0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0","0","1",COLUMNS($B1:B1)))
    copied across to Q2
    Adjust ranges to suit
    Last edited by DonkeyOte; 09-07-2009 at 03:04 AM. Reason: typo in narrative - formulae unchanged

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

    Re: COUNT involving several columns

    I should also have added the formulae for calculating R & S based off this 0/1 approach, eg:

    SKU 1-4
    R2: =COUNTIF(T5:T100,"*1*:0:0:0:0:0:0:0:0:0:0:0:0")
    
    SKU 5-16
    S2: =COUNTIF(T5:T100,"0:0:0:0:*1*")

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

    Re: COUNT involving several columns

    you could use some longish sumproducts for your example it shouldnt affect performance
    Attached Files Attached Files
    "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

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,697

    Re: COUNT involving several columns

    Try this formula in B2 copied across

    =SUMPRODUCT((B5:B100>0)*($R5:$R100+$S5:$S100=B5:B100))

  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: COUNT involving several columns

    i like it better the looooong way lol

  7. #7
    Registered User
    Join Date
    07-18-2008
    Location
    Australia
    Posts
    40

    Re: COUNT involving several columns

    Thanks a lot guys. Appreciate that!

+ 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