+ Reply to Thread
Results 1 to 6 of 6

Counting consecutive non-zero values

  1. #1
    Registered User
    Join Date
    09-26-2007
    Posts
    6

    Counting consecutive non-zero values

    Hi,

    I am struggling to find a way to count a number of consecutive non-zero values across 33 columns without resorting to a horrid nested-IF formula.

    I'm using Excel 2003 and each row I have is an account (there are 5572 accounts). I have been tasked to check if a customer has made 6 consecutive payments (held on each row in columns K to AQ.

    If a customer has made less than 6 consecutive payments then I need to multiply the total collected by 40%. If the customer has made more than 6 consecutive payments then I need to multiply the first six payments by 40% and then each subsequent payment (consecutive or otherwise) by 20% and total the figure.

    Can anyone help?

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    If you want to determine whether 6 consecutive payments occur anywhere in the row (not necessarily the latest payments) and non-payment is zero or blank, try this "array formula" in row 2 copied down

    =MAX(FREQUENCY(IF(K2:AQ2>0,COLUMN(K2:AQ2)),IF( K2:AQ2=0,COLUMN(K2:AQ2))))>5

    needs to be confirmed with CTRL+SHIFT+ENTER [hold down CTRL and SHIFT keys and press ENTER so that curly braces like { and } appear around the formula in the formula bar]

    gives TRUE if there are 6 consecutive, otherwise FALSE

  3. #3
    Registered User
    Join Date
    09-26-2007
    Posts
    6
    Thats fantastic thanks - now I just need to work out a way to find the reference of the sixth consecutive payment and sum everything to the left of it (including itself) and sum everything to the right of it.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    What if there are two or more runs of 6 consecutive payments (or more), are you looking for the first?

  5. #5
    Registered User
    Join Date
    09-26-2007
    Posts
    6
    Quote Originally Posted by daddylonglegs
    What if there are two or more runs of 6 consecutive payments (or more), are you looking for the first?
    Only the first one is of any consequence.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Quote Originally Posted by RichH6109

    If a customer has made less than 6 consecutive payments then I need to multiply the total collected by 40%. If the customer has made more than 6 consecutive payments then I need to multiply the first six payments by 40% and then each subsequent payment (consecutive or otherwise) by 20% and total the figure.
    OK, slightly different approach, to give the above, i.e. 40% of all payments up to first occurrence of sixth consecutive and then 20% thereafter try this formula in row 2 "array entered" and copied down column

    =(LOOKUP(9.99999999999999E+307,CHOOSE({1,2},SUM (K2:AQ2),SUM(OFFSET(K2,,,,MATCH(6,COUNTIF( OFFSET(K2,,COLUMN(K2:AL2)-COLUMN(K2),,6),">0"),0)+5))))+SUM(K2:AQ2))/5

    Note: one of the ranges says K2:AL2 - this is deliberate.
    Last edited by daddylonglegs; 09-26-2007 at 07:24 PM.

+ 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