+ Reply to Thread
Results 1 to 8 of 8

Count of Consecutive Zeros excluding #N/A

  1. #1
    Registered User
    Join Date
    07-08-2014
    Location
    Brisbane, Australia
    MS-Off Ver
    2013
    Posts
    3

    Count of Consecutive Zeros excluding #N/A

    This is my column of data:


    7
    8
    9
    7
    5
    7
    6
    9
    11
    6
    7
    2
    6
    2
    4
    1
    1
    0
    1
    3
    1
    0
    0
    2
    1
    2
    0
    1
    3
    1
    1
    0
    1
    0
    0
    0
    0
    0
    0
    #N/A
    #N/A
    #N/A
    #N/A
    #N/A

    The data in this column is the result of a sumproduct function and returns an #N/A error so that dynamic graphing can occur after input of primary data on another sheet.

    The problem I am having is I wish to be able to show:

    The Current Run of Zero events.
    The longest run of zero events
    The nth longest run of zero events (i.e. 2nd or 3rd etc.)

    The formula I have in the next column is currently this:

    =IF(OR(H3<>0,H3="#N/A"),"",MATCH(TRUE,H3:H$112<>0,0)-1)

    I can then use a max formula of the new column to find the longest run.

    The problem I have is that the latest run is of 7 consecutive 0s and it does not tell me this. It is resulting in an #N/A error because of the #N/A outputs in the first column. The longest run of Zeros I currently get from my max formula is 2.

    I have ready other formulas using FREQUENCY etc and have tried to adapt them to my situation but seem to be failing spectacularly. Any help would be greatly appreciated :)

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count of Consecutive Zeros excluding #N/A

    hey bro,
    use this...

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


    Say thanks, click *

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Count of Consecutive Zeros excluding #N/A

    Pl see attached file. Helper column is used.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 07-09-2014 at 04:08 AM.

  4. #4
    Registered User
    Join Date
    07-08-2014
    Location
    Brisbane, Australia
    MS-Off Ver
    2013
    Posts
    3

    Re: Count of Consecutive Zeros excluding #N/A

    Thank you so much for your help!!

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count of Consecutive Zeros excluding #N/A

    Will the #N/A errors always be at the bottom of the data?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    07-08-2014
    Location
    Brisbane, Australia
    MS-Off Ver
    2013
    Posts
    3

    Re: Count of Consecutive Zeros excluding #N/A

    Quote Originally Posted by Tony Valko View Post
    Will the #N/A errors always be at the bottom of the data?
    Hi Tony,

    Yes the data will always have the errors at the bottom as it reflects that data has not yet been entered on the primary data sheet yet so far this year.

    This problem has been solved already though. I modified the formula given to me earlier by kvsrinivasamurthy & this is what it now looks like:

    =IFERROR(IF(AND(H3<>0,H2=0),0,IFERROR(IF(AND(H3=0,H2<>0),MATCH(FALSE,IFERROR(H3:H$112,"")=0,-1),"")-1,"")),"")

    in a helper column followed by:

    =LARGE('Statistics (2)'!$H$3:$H$112,'Dashboard 2'!$D$7).

  7. #7
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Count of Consecutive Zeros excluding #N/A

    Try this:

    No helper column is required.

    =MAX(FREQUENCY(IF(ISNUMBER(A1:A44),IF(A1:A44=0,ROW(A1:A44))),IF(ISNUMBER(A1:A44),IF(A1:A44<>0,ROW(A1:A44)))))

    Array formula: Press Ctrl+Shift+Enter, not just Enter

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count of Consecutive Zeros excluding #N/A

    Quote Originally Posted by gaffee View Post
    Yes the data will always have the errors at the bottom
    Ok, no need for helper columns.

    Both of the following formulas are array formulas**.

    For the current streak (the bottom-most streak in the column):

    =IFERROR(LOOKUP(1000,1/(1/FREQUENCY(IF(ISNUMBER(H2:H45),IF(H2:H45=0,ROW(H2:H45))),IF(ISNUMBER(H2:H45),IF(H2:H45<>0,ROW(H2:H45)))))),"")

    For the 1st, 2nd, 3rd etc. longest streaks:

    =IFERROR(1/(1/LARGE(FREQUENCY(IF(ISNUMBER(H$2:H$45),IF(H$2:H$45=0,ROW(H$2:H$45))),IF(ISNUMBER(H$2:H$45),IF(H$2:H$45<>0,ROW(H$2:H$45)))),ROWS(A$1:A1))),"")

    Copy down until you get blanks.

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

+ 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. Replies: 20
    Last Post: 05-02-2014, 06:42 AM
  2. Excluding zeros from count
    By ihosey in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-31-2014, 09:40 AM
  3. Count longest consecutive run of zeros
    By TheRobsterUK in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-17-2013, 08:02 AM
  4. [SOLVED] Average for non-consecutive cells excluding zeros (even when they all contain zeros)
    By pao13 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2012, 04:32 PM
  5. [SOLVED] Average, Excluding Zeros, Non-Consecutive Range
    By Coal Miner in forum Excel General
    Replies: 9
    Last Post: 08-04-2005, 06:05 PM

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