+ Reply to Thread
Results 1 to 9 of 9

Find a peak number over a series of dates

  1. #1
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Find a peak number over a series of dates

    I have a series of dates in column A in date order, against each date there is a variable numeric value.
    Starting at the first date and for each date after I would like to add the numeric values for 22 days forward. This is to find the peak number for any series of 22 consecutive days.

    Hope this makes sense

    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,726

    Re: Find a peak number over a series of dates

    Not sure why you want to "add the numeric values" if you want to get the peak - you need to use the MAX function.

    What cell is your starting date in?

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Re: Find a peak number over a series of dates

    Thanks for replying.

    Dates start in a4, values in g4.

  4. #4
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Re: Find a peak number over a series of dates

    I have managed to solve this myself, although I doubt it is the most efficient solution. I'll share anyway.

    =IFERROR(SUM(IF(A4:A1000>=A4,IF(A4:A1000<=A4+22,C4:C1000))),"") as an array formula.

    This will determine the series of dates of 22 days that contain the peak value.

    Then use this =INDEX(A4:A1000,MATCH(MAX(H4:H1000),H4:H1000,0)) to return the date of the first occurence of the peak value.

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Find a peak number over a series of dates

    There are a couple of ways at looking at your problem.

    The first is that the days are consecutive days without gaps. The second way is that there are gaps in the dates

    This formula will sum 22 days into the future....total of 23 days....the same as your formula. My formula for the date is the same as yours and returns the same date.


    This give the sum for 22 "dates" into the future
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If there are gaps in the dates then this will work for 22 "days" into the future:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by newdoverman; 11-01-2014 at 01:59 PM.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  6. #6
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Find a peak number over a series of dates

    Hi

    another possible approach (ispired to newdoverman's proposal) could be

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


    Regards
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  7. #7
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Find a peak number over a series of dates

    @canapone

    That works very well like the first situation that I and sipa gave.....consecutive dates without gaps in the dates. I thought, after posting, that there could be great gaps in the dates that would/could skew the results from having as little as 1 day to as many as 23 days. I then added the SUMIFS formula that would take the actual dates into consideration. The formula for returning the date with the highest value remains the same as what sipa posted.

    What are your thoughts/

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Find a peak number over a series of dates

    Here is yet another way to calculate the sum using actual date spreads of 23 days and not counts of consecutive days:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by newdoverman; 11-01-2014 at 02:27 PM.

  9. #9
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Re: Find a peak number over a series of dates

    Thank you both for the reply's and the alternative methods too.

    Newdoverman, this formula returns the same result as mine =SUMIFS(C4:C1000,A4:A1000,">="&A4,A4:A1000,"<="&A4+22)

    as does this one too, =SUMPRODUCT((A4:A1000>=A4)*(A4:A1000<=A4+22),C4:C1000)

    Canapone, your formula, =SUM(C4:INDEX(C4:C1000,23)) yields the same result as Newdoverman with this =SUM(OFFSET(C4,0,0,23))

    But neither of these return the result I'm looking for. At least I now have 3 alternative solutions to work with.
    I Appreciate your time.

+ 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. Electricity Calculations based on Peak and Off Peak Rate
    By mrwrighty in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-11-2014, 07:43 AM
  2. Counting the peak & non peak hours between two dates?
    By zeroprobe in forum Excel General
    Replies: 3
    Last Post: 12-09-2013, 06:53 AM
  3. Replies: 5
    Last Post: 05-18-2013, 11:59 AM
  4. Formulas - converting dBdsx to Volts peak to peak
    By alex148 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-11-2007, 09:49 AM
  5. Replies: 1
    Last Post: 03-13-2006, 07:27 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