+ Reply to Thread
Results 1 to 16 of 16

How do I isolate part of an array (trying to isolate non-zero consecutive values)

  1. #1
    Registered User
    Join Date
    03-15-2013
    Location
    sf
    MS-Off Ver
    Excel 2007
    Posts
    13

    How do I isolate part of an array (trying to isolate non-zero consecutive values)

    I have a huge problem. I would like to isolate part of an array where the value is 1 for several consecutive months. I know how to calculate the maximum number of consecutive months but I would like to find out when this started. For example see below:

    1. The first row I know there are 8 consecutive months and it starts on April.
    2. The second row, there are two groups of consecutive months, but I am currently interested in the bigger group of 4 elements. I would like for it to spit out "september"

    Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec
    1 1 1 1 1 1 1 1
    1 1 1 1 1 1 1

    Thanks! This is my first post so I hope this isn't a silly question.
    Attached Files Attached Files
    Last edited by leena1126; 11-28-2014 at 04:55 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    What is your expected result?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    03-15-2013
    Location
    sf
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    I would like it to give me April for the first array and Sept for the second array.

    I think the excel file has a better view of the data. Sorry the formatting looks off once I hit submit.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    Hi.

    Array formula** for row 2:

    =INDEX(A$1:L$1,,MATCH(MAX(FREQUENCY(IF(A2:L2=1,COLUMN(A2:L2)),IF(A2:L2<>1,COLUMN(A2:L2),0))),FREQUENCY(IF(A2:L2=1,COLUMN(A2:L2)),IF(A2:L2<>1,COLUMN(A2:L2),0)),0)-MAX(FREQUENCY(IF(A2:L2=1,COLUMN(A2:L2)),IF(A2:L2<>1,COLUMN(A2:L2),0))))

    Copy down as required.

    Regards


    **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).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Registered User
    Join Date
    03-15-2013
    Location
    sf
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    You're amazing!

    Ok second question....in the next column, how can I get the next month start of a consecutive array. The result I would get for the first array would not be applicable, but for the second array I would get January.

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    Quote Originally Posted by leena1126 View Post
    You're amazing!

    Ok second question....in the next column, how can I get the next month start of a consecutive array. The result I would get for the first array would not be applicable, but for the second array I would get January.
    Is this only ever going to be required for the first and second largest streaks? Or are you potentially going to be wanting to extend this for any number of streaks?

    Regards

  7. #7
    Registered User
    Join Date
    03-15-2013
    Location
    sf
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    potentially any number. But you also have to consider what happens if within a row I have multiple groups that have the same number of "1"s.

    Let's say:
    J F M A M J J A S O N D
    1 1 1 1 1 0 0 1 1 1 1 1 --> Results should be January. Next column result should be August
    1 0 0 1 1 0 1 1 0 1 1 1 --> Result should be October, next column April, next column July.

    I hope that makes sense.

    TIA!

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    Does the second of those not require a fourth column to list "January"? Or are strings of a single month only not to be considered?

    Regards

  9. #9
    Registered User
    Join Date
    03-15-2013
    Location
    sf
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    No, Jan would be included in the next column. I would probably take this out to 6 columns (assuming every other month is a "1").

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    Thanks.

    =IF(COLUMNS($A:A)>SUM(0+(FREQUENCY(IF($A2:$L2=1,COLUMN($A2:$L2)),IF($A2:$L2<>1,COLUMN($A2:$L2),0))>0)),"",INDEX($A$1:$L$1,,MATCH(LARGE(FREQUENCY(IF($A2:$L2=1,COLUMN($A2:$L2)),IF($A2:$L2<>1,COLUMN($A2:$L2),0))+1/(10^3*ROW(INDIRECT("1:"&1+COLUMNS($A2:$L2)))),COLUMNS($A:A)),FREQUENCY(IF($A2:$L2=1,COLUMN($A2:$L2)),IF($A2:$L2<>1,COLUMN($A2:$L2),0))+1/(10^3*ROW(INDIRECT("1:"&1+COLUMNS($A2:$L2)))),0)-LARGE(FREQUENCY(IF($A2:$L2=1,COLUMN($A2:$L2)),IF($A2:$L2<>1,COLUMN($A2:$L2),0)),COLUMNS($A:A))))

    Regards

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    I should've mentioned that this formula is to be array-entered somewhere in row 2 and then copied to the right until you start to get blanks for the results.

    Regards

  12. #12
    Registered User
    Join Date
    03-15-2013
    Location
    sf
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    Totally confused since you use both rows here. I'm not sure what to substitute in...also not sure why column A is used.

    Can you please explain a little?

  13. #13
    Registered User
    Join Date
    03-15-2013
    Location
    sf
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    just saw your latest reply....still confused.

    start on the second row. then copy to the right. yep, it's obvious it's a ctrl-shift-enter formula. thanks for the friendly reminder though.

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    Quote Originally Posted by leena1126 View Post
    just saw your latest reply....still confused.

    start on the second row. then copy to the right. yep, it's obvious it's a ctrl-shift-enter formula. thanks for the friendly reminder though.
    I apologize for the unintended condescension.

    Quote Originally Posted by leena1126 View Post
    Totally confused since you use both rows here. I'm not sure what to substitute in...also not sure why column A is used.
    I'm not sure what you mean. I based this on your attachment. The formula I provided is placed somewhere in row 2, e.g. M2, and then copied to the right.

    It can also be copied down to give similar results for the entries in row 3.

    Regards

  15. #15
    Registered User
    Join Date
    03-15-2013
    Location
    sf
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    Sorry I got it to work. It's 230am here.

    I don't know how you did it but you're amazing. I wish I had your skills

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How do I isolate part of an array (trying to isolate non-zero consecutive values)

    Glad you got there in the end.

    And you're welcome!

+ 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. Can you use an excel function to isolate part of a text string?
    By CharCat in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-27-2012, 02:05 AM
  2. Replies: 14
    Last Post: 06-04-2012, 08:41 AM
  3. Isolate values, sort and highlight
    By gberna2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2010, 02:27 PM
  4. [SOLVED] Isolate array formulas in a range
    By M. Authement in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2006, 01:55 PM
  5. [SOLVED] How do I isolate the Fractional part of a number in Excel VB?
    By Cumulous in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2006, 05:00 PM

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