+ Reply to Thread
Results 1 to 10 of 10

Length (count) of sequences with start and end condition

  1. #1
    Registered User
    Join Date
    04-14-2020
    Location
    Australia
    MS-Off Ver
    365
    Posts
    10

    Question Length (count) of sequences with start and end condition

    I have some acceleration data for which I am trying to count the length of sequences given a set of conditions. In this case I want to count the length of a sequence when the acceleration moves > 2.78 and then drops back below 0.

    An example would be

    [-1.1, -1, 0, 1.2, 1.8, 2, 2,88, 2.86, 2.53, 1.98, 1.21, 0.89, 0.11, -0.21]

    The return result here would be a count of 7 (2,88, 2.86, 2.53, 1.98, 1.21, 0.89, 0.11)

    I have done this previously to identify the largest sequence with one condition using the following formula

    {=MAX(FREQUENCY(IF($T2:$T81781>2.78,ROW($T2:$T81781)),IF($T2:$T81781<=2.78,ROW($T2:$T81781))))}

    Using the above example, the result using this formula would be 2 (2.88, 2.86)

    Help please

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Length (count) of sequences with start and end condition

    May be:

    Please Login or Register  to view this content.
    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Quang PT

  3. #3
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Length (count) of sequences with start and end condition

    @jake,

    if the sequence were: [2,3,4,2,1,2,3,2,1,0,-1]

    is the result 10, or 5 ?

    i.e. does the drop to 1 and subsequent increase invalidate the [3,4,2,1,2] sequence

    I suspect you will want to use either a) a 'key' adjacent to your T values to label/group specific sequences, or b) a UDF

  4. #4
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Length (count) of sequences with start and end condition

    Hi,
    please see below and attched in G4:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Limor_OP; 07-10-2020 at 05:58 AM.

  5. #5
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Length (count) of sequences with start and end condition

    Hi XLent,
    I will try to answer though not instead of Jake, so if I understood him correct - he wants to find the 1st instance in a sequence where it is > 2.78 and count all subsequent numbers until it reached a negetive (<0) and stop there.
    So in your example 3 would be the start point (the instance where >2.78), and it will stop counting in 0 (since the next value is negative).
    The answer then should be 9

  6. #6
    Registered User
    Join Date
    04-14-2020
    Location
    Australia
    MS-Off Ver
    365
    Posts
    10

    Re: Length (count) of sequences with start and end condition

    Hi XLent,

    In my case the answer would be 10

    Thanks!

  7. #7
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Length (count) of sequences with start and end condition

    jake_jennings1
    Thant means I didnt understand you correct.
    Can you lookthe file at post # 4 and advise if this is the result you are expecting?

  8. #8
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Length (count) of sequences with start and end condition

    Quote Originally Posted by jake_jennings1 View Post
    Hi XLent, In my case the answer would be 10
    In which case, given size of range and number of potential sequences, I'd personally suggest you do following:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-14-2020
    Location
    Australia
    MS-Off Ver
    365
    Posts
    10

    Re: Length (count) of sequences with start and end condition

    Hi everyone,

    Thanks for all your help. I ended up figuring it out using python. This allowed me to identify multiple occurrences within one set of data and then export back into excel.
    Appreciate everyone's help!

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Length (count) of sequences with start and end condition

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. How can I retrieve count of sequences of product
    By hovsee in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-14-2020, 11:23 PM
  2. detect within the 8 trios in sequences the sequences in the red color
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2019, 04:34 PM
  3. [SOLVED] Count Exact Sequences
    By xjohnson in forum Excel General
    Replies: 5
    Last Post: 11-30-2018, 11:30 AM
  4. [SOLVED] Work out average length of sequences in a column
    By Supersadie in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 07-04-2018, 05:34 AM
  5. Count length of sequences of negative numbers
    By cad1llac in forum Excel General
    Replies: 15
    Last Post: 08-06-2015, 01:45 PM
  6. Calculating the length, start, and end dates of a series of events
    By CharlieDog in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-03-2014, 04:53 PM
  7. defining a years length(start and end dates)
    By wheefus in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-13-2008, 11:44 AM

Tags for this Thread

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