+ Reply to Thread
Results 1 to 8 of 8

Count the number of times a value greater than x is in an array

  1. #1
    Registered User
    Join Date
    02-27-2006
    Location
    Oxford England
    MS-Off Ver
    2007
    Posts
    54

    Count the number of times a value greater than x is in an array

    Hi,

    I have a list of people who download music, it shows their name in column A, then the number of songs downloaded in B.

    They can appear in the list many times and can download songs once or many times.

    I would like to count the number of times a spedific person downloads more than X songs.

    Ive gone mad with lookups and if formulas and need some help.

    I just want to say for person "joe blogs" and X = 10 it will tell me how many times Joe downloaded 10 or more songs.

    Thanks.

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

    Re: Count the number of times a value greater than x is in an array

    Quote Originally Posted by Ainsley
    They can appear in the list many times and can download songs once or many times.
    On which basis - does X represent unique songs ?

    Also please clarify as to the XL version in use.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,622

    Re: Count the number of times a value greater than x is in an array

    Please post a sample workbook with some typical data.

    Please also update your profile and/or indicate which version of Excel you are using.

    With Excel 2003, you'd use SUMPRODUCT; with Excel 2007, you'd use SUMIFS (or SUMPRODUCT)


    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Re: Count the number of times a value greater than x is in an array

    If you have Excel 2007 onwards:

    =COUNTIFS(A:A,"Joe Bloggs",B:B,">10")

    Otherwise:

    =SUMPRODUCT(--(A:A="Joe Bloggs")*(B:B>10))

    (this might be slow to calculate, so better to give a smaller range rather than a whole column - i.e. A1:A1000 and B1:B1000)

    Hope this helps.

  5. #5
    Registered User
    Join Date
    02-27-2006
    Location
    Oxford England
    MS-Off Ver
    2007
    Posts
    54

    Re: Count the number of times a value greater than x is in an array

    Im using 2007.

    In my table I could have loads of people in column A, and in B it will have the number of songs they downloaded.

    People can appear in the list several times and they can download 1 or more songs. So Joe Blogs can appear say twice, once he downloads 10 songs, the second time 20.

    I would like to be able to lookup how many times Joe Blogs downloaded more than 15 songs, so in my example it would be Once. That is the person downloaded more than 15 songs only once.

    Hope that makes sence.

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

    Re: Count the number of times a value greater than x is in an array

    Quote Originally Posted by brokenbiscuits View Post
    If you have Excel 2007 onwards

    ...
    Otherwise:

    =SUMPRODUCT(--(A:A="Joe Bloggs")*(B:B>10))

    (this might be slow to calculate, so better to give a smaller range rather than a whole column - i.e. A1:A1000 and B1:B1000)
    @bb, you can't use entire column references with SUMPRODUCT prior to XL2007 (would generate #NUM! error so have to be restricted anyway)

    (also FWIW the double unary coercion is unnecessary given multiplication of arrays)

  7. #7
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Re: Count the number of times a value greater than x is in an array

    Yeah, I never really fully got my head around SUMPRODUCT before we switched to 2007, especially the coercion stuff, and thankfully now I don't ever really need to!

    Ainsley, from your further explanation, the 2007 example I posted above should work, no?

  8. #8
    Registered User
    Join Date
    02-27-2006
    Location
    Oxford England
    MS-Off Ver
    2007
    Posts
    54

    Re: Count the number of times a value greater than x is in an array

    Broken Biscuits - thanks, the Sumproduct worked.

+ 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