+ Reply to Thread
Results 1 to 5 of 5

Extending Formula: Counting days back to last value

  1. #1
    Registered User
    Join Date
    07-01-2016
    Location
    Melbourne
    MS-Off Ver
    2013
    Posts
    22

    Extending Formula: Counting days back to last value

    Hi All,

    I am trying to extend a formula that I've written that would allow me to count the days including & before the last date in a column where there was last a value above 0 in a column. Eg: If the last date was 1-Apr-13, in the below table, the number of days before there was a value in column B would be 2.

    To note; I will be importing a list with dates that vary in length, due to public holidays/ weekends/ differing start & end dates, so the range cannot be fixed, it will have to find the last value in the list and work backwards from there.

    A B
    1 28-Mar-13 22000
    2 29-Mar-13 0
    3 1-Apr-13 0

    I've found half a solution, in that a formula I have created will show me if there has been no occurrence on the last & second last day on a column, with no range constraints.

    The formula will show me a result of '0' if the last date (A3) in Column A has any corresponding value above 0 in B.

    It will show me '1' if there was a 0 value in B3, but a value above 0 in the corresponding cell in column B for date before the last date (A2) exists.

    It will show a '2+' if the formula returns a 0 value in B3 & B2.

    I'm unsure how to extend this for one more day without the formula tripping up over itself and only presenting '2+' despite there being values in B to the end of the column, or in other words, against the last date. Optimally, I would like to run the formula back to the last time there was a value in column B that was greater than 0. If this is too time consuming, reaching 5+ days would be acceptable.

    Here's my rather inelegant formula - "=IFERROR(IF(1=(IF(0<(LOOKUP(2,1/(B:B<>""),B:B))/((LOOKUP(2,1/(B:B<>"")))), 0,1)),(IF(1=(LOOKUP((SUM((MAX(A:A))-1)),A:A,B:B)/(LOOKUP(SUM((MAX(A:A))-1),A:A,B:B))),1,0)),0),"+2")"

    If anyone has a more streamlined way of coming to the same conclusion, or would know how to build on this, let me know.

    Thanks in advance.
    Last edited by samcoarse; 07-06-2016 at 03:18 AM.

  2. #2
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Extending Formula: Counting days back to last value

    Hi Welcome to Excel Forum,

    Can you please upload your sample workbook clean you confidential information and attached a sample with expect result.

    Go to advance and click on paper clip icon and attach workbook.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,427

    Re: Extending Formula: Counting days back to last value

    It is best to avoid referencing whole columns, but try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    It is best to use references that are a bit larger than anticipated need. If you think your data will have about 10,000 rows make the range B1:B15000.
    Dave

  4. #4
    Registered User
    Join Date
    07-01-2016
    Location
    Melbourne
    MS-Off Ver
    2013
    Posts
    22

    Re: Extending Formula: Counting days back to last value

    Hi FlameRetired,

    This worked perfectly.

    Amazing that I can strain over this for hours (first week using Excel) and an elegant, more streamline answer can come back in minutes.

    Appreciate your efforts.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,427

    Re: Extending Formula: Counting days back to last value

    samcoarse,

    Thank you for the feedback and kind words. Glad to help.

    Also I overlooked this was your first post. Welcome to the forum.

+ 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] Formula for counting back cells with zero (until positive value)
    By deanhardman in forum Excel General
    Replies: 2
    Last Post: 07-15-2015, 09:23 PM
  2. How do I convert years, months, days back to complete days
    By Nisha Dhawan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-13-2014, 03:21 AM
  3. Formula to look back 90 days and drop point on attendance tracker
    By tmorr24 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-22-2014, 01:27 AM
  4. Replies: 3
    Last Post: 11-22-2012, 11:19 PM
  5. [SOLVED] Counting Number of Times a Value is Repeated REPEATEDLY (Back to Back)
    By patrickfshield in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-06-2012, 04:45 AM
  6. [SOLVED] Counting days back from a date
    By blkirby in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-20-2012, 07:24 PM
  7. [SOLVED] Need formula to calculate days between dates or back date
    By KVN in forum Excel General
    Replies: 3
    Last Post: 05-03-2006, 05:15 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