+ Reply to Thread
Results 1 to 11 of 11

Excel Formula to find a Sequence

  1. #1
    Registered User
    Join Date
    09-05-2006
    Posts
    14

    Excel Formula to find a Sequence

    I am not very good with excel but I am looking for a formula that would calculate the following

    A B
    3 1 True
    4 2 True
    3 5 False Transition
    6 7 False
    5 8 False
    6 5 No Sequence Transition
    8 9 No Sequence

    For each time A is greater than B in a sequence of 2 or more rows it says True. If A is less than B in a sequence of 2 or more rows it turns up False. When a sequence starts, it needs to read False Transition or True Transition. If there is no sequence, meaning A is greater than B in the first row, then A is less than B in the next row and then back to A greater than B in the third row, it turns up NoSequence.

    Then I need to calculate the percentage of True, False, No Sequence in the entire sample size.

    Sorry if this is confusing.

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Excel Formula to find a Sequence

    See attached, I hope it's what you need.

    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-05-2006
    Posts
    14

    Re: Excel Formula to find a Sequence

    Antonio,

    Thanks for the help. The count and percent look good but I cant seem to find the formula that identifies if it is a True, False, True Transition, False Transition, No Sequence or No Sequence Transition. I have thousands of lines of data I am trying to identify the sequences with a label from above (True, False, True Transition, False Transition, No Sequence, No Sequence Transition)

    Thanks

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Excel Formula to find a Sequence

    The transition rule does not apply to the very first line then?

  5. #5
    Registered User
    Join Date
    09-05-2006
    Posts
    14

    Re: Excel Formula to find a Sequence

    Correct. The transition is when the sequence is broken and it the first row of the new sequence.

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Excel Formula to find a Sequence

    Try this. A bit messy but it works for your example. No idea if it will work for other datasets, the last row part may not work.
    Please Login or Register  to view this content.
    EDIT: ok, I know the last row is wrong unless it is no sequence so I will look at that.

    EDIT2: have revised code above. Am sure it could be shortened but for the time being try that.
    Last edited by StephenR; 05-14-2010 at 09:36 AM.

  7. #7
    Registered User
    Join Date
    09-05-2006
    Posts
    14

    Re: Excel Formula to find a Sequence

    Thanks for the help. I tried to run the code above but Im not sure if my computer is just not powerful enough or the code was wrong. I put it in Visual Basic Editor code section and hit run. The hour glass for a mouse never went away after 1 hour. Any thoughts?

  8. #8
    Registered User
    Join Date
    09-05-2006
    Posts
    14

    Re: Excel Formula to find a Sequence

    attached file?
    Attached Files Attached Files

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

    Re: Excel Formula to find a Sequence

    Out of curiosity - based on your latest sample - does the below return expected results ?

    C2:
    =IF(OR(SIGN(N(A2)-N(B2))=SIGN(N(A3)-N(B3)),SIGN(N(A2)-N(B2))=SIGN(N(A1)-N(B1))),PROPER((A2-B2>0)),"No Sequence")&REPT(" Transition",SIGN(N(A2)-N(B2))<>SIGN(N(A1)-N(B1)))
    copied down for all rows

  10. #10
    Registered User
    Join Date
    09-05-2006
    Posts
    14

    Re: Excel Formula to find a Sequence

    YES! Thanks. No I need to figure the percent of Falses, Trues, No Sequence in the total sample. etc

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

    Re: Excel Formula to find a Sequence

    see COUNTIF function in XL Help (or consider use of a Pivot Table - intro. link can be found in my sig.)

+ 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