+ Reply to Thread
Results 1 to 6 of 6

Counting the Spans of Zeros between non-zero values

  1. #1
    Registered User
    Join Date
    07-01-2016
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    4

    Question Counting the Spans of Zeros between non-zero values

    I have data of the monthly total of purchases by each customer. It looks something like this: 0,0,0,100,200,0,0,300,0,0,0,20,0,250,0,0. All in separate cells in a row. I want to be able to return the values of 2,3,1. I need to find a way to count the amount of zero values between the non zero values. With or without the amount of zeros following the last nonzero number is a little less important.
    For reference I have a formula to count to the amount of months since the first purchase and also the amount of months since the last purchase. They are the following: =COUNT(DD2:INDEX(A2:DD2,MATCH("",T(1/A2:DD2),0))) and =ROWS(A2:DD2)-MATCH(2,1/(A2:DD2>0))+108.
    Any Help would be greatly appreciated.
    Thanks

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,803

    Re: Counting the Spans of Zeros between non-zero values

    I think most of us are more used to working down the screen in columns rather than across the screen in rows, so it is difficult to imagine your set-up - it would help if you attached a sample Excel workbook.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Pete

  3. #3
    Registered User
    Join Date
    07-01-2016
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    4

    Re: Counting the Spans of Zeros between non-zero values

    I attached the an example file that is truncated to 500 entries. It's in rows like this because that is the best way to get it out of our database.
    Thanks again.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Counting the Spans of Zeros between non-zero values

    Try the array formula below in DL2. Confirm it with Ctrl + Shift + Enter instead of the regular Enter. Fill down through all of your rows, then fill right as far as you need to. In each column it should list the size of the gap between non-zero entries. See attached for (hopefully) more clarity:

    =IFERROR(SMALL(IF($G2:$DJ2>0,COLUMN($G2:$DJ2)),COLUMN(A:A)+1)-SMALL(IF($G2:$DJ2>0,COLUMN($G2:$DJ2)),COLUMN(A:A))-1,"")

    The results I've checked appear to hold up?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-01-2016
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    4

    Re: Counting the Spans of Zeros between non-zero values

    Thanks so much, You are truly an amazing person. This is exactly what I was looking for.

  6. #6
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Counting the Spans of Zeros between non-zero values

    Glad I could help, good luck!

+ 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. [SOLVED] Counting 1 between 2 zeros starting from given input
    By Sekars in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 06-23-2016, 07:34 AM
  2. Replies: 7
    Last Post: 02-11-2015, 11:23 AM
  3. counting zeros in rows of data
    By runner in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-14-2015, 06:18 PM
  4. [SOLVED] Counting number of zeros between two non zero values in a string
    By simone77 in forum Excel General
    Replies: 13
    Last Post: 03-27-2012, 05:19 PM
  5. Replies: 3
    Last Post: 10-26-2010, 05:12 PM
  6. Counting consecutive zeros at end of range
    By darkyam in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-16-2010, 01:45 PM
  7. counting zeros
    By hoshino in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-25-2008, 10:31 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