+ Reply to Thread
Results 1 to 9 of 9

count the number of consecutive values >=2

  1. #1
    Registered User
    Join Date
    06-14-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 & MS365
    Posts
    15

    count the number of consecutive values >=2

    I would like to count the number of consecutive values >=2 in a row.

    Eg:-
    1 2 3 2 3 2 2 2 2 1 1 1 3 3 2 2 1 1

    The returned value would be 8, because the 2nd to the 9th figure are all greater or equal to 2

    OR

    1 2 3 1 2 1 3 2 1 3 2 3 4 3 1 2 3 1

    The returned value would be 5, because the 10th to the 14th figure are all greater or equal to 2
    Last edited by jomuir; 06-14-2011 at 11:20 AM.

  2. #2
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: count the number of consecutive values >=2

    Quote Originally Posted by jomuir View Post
    I would like to count the number of consecutive values >=2 in a row.

    Eg:-
    1 2 3 2 3 2 2 2 2 1 1 1 3 3 2 2 1 1

    The returned value would be 8, because the 2nd to the 9th figure are all greater or equal to 2
    isnt the answer 12 and not 8?

    =COUNTIF(A2:R2,">=2")

    Oh sorry - you said consecutive!
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

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

    Re: count the number of consecutive values >=2

    I assume you want the maximum number of consecutive values >= 2. For that try this formula

    =MAX(FREQUENCY(IF(A2:R2>=2,COLUMN(A2:R2)),IF(A2:R2<2,COLUMN(A2:R2))))

    confirmed with CTRL+SHIFT+ENTER
    Audere est facere

  4. #4
    Registered User
    Join Date
    06-14-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 & MS365
    Posts
    15

    Re: count the number of consecutive values >=2

    No, that gives the answer 6 - it appears to coult all the numbers less than 2.

    so if I had 1 1 1 1 1 1 1 1 1 1 1 2 2 2 3 1 1 1 then the answer I am looking for is 4, based on the numbers 2, 2, 2 & 3 being >=2 and consecutive
    Last edited by jomuir; 06-14-2011 at 11:12 AM.

  5. #5
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: count the number of consecutive values >=2

    Hi,

    The solution DDL posted works for me - did you give it a try?
    Attached Files Attached Files
    Hope that helps,

    Colin

    RAD Excel Blog

  6. #6
    Registered User
    Join Date
    06-14-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 & MS365
    Posts
    15

    Re: count the number of consecutive values >=2

    Sorry, it does work in your example....not sure why it dod not when I entered it in!!

    Thanks daddylonglegs......again not sure why it did not work when I tried it at first

  7. #7
    Registered User
    Join Date
    03-20-2013
    Location
    Bucharest
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: count the number of consecutive values >=2

    does not work for me as well

  8. #8
    Registered User
    Join Date
    03-03-2017
    Location
    Berlin
    MS-Off Ver
    2016
    Posts
    1

    Re: count the number of consecutive values >=2

    Worked for me with the following formula
    =MAX(FREQUENCY(IF(A2:R2>=2;COLUMN(A2:R2));IF(A2:R2<2;COLUMN(A2:R2))))

    Very similar to the one originally posted.
    The attached Excel file by Colin Legg has an identical formula.

  9. #9
    Registered User
    Join Date
    03-26-2016
    Location
    São Paulo - Brazil
    MS-Off Ver
    2016
    Posts
    48

    Re: count the number of consecutive values >=2

    Senhores

    CTRL+SHIFT+ENTER

    Decio

+ 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