+ Reply to Thread
Results 1 to 19 of 19

Help with multiple dates and values to count occurrences

Hybrid View

  1. #1
    Registered User
    Join Date
    07-24-2014
    Location
    Arizona
    MS-Off Ver
    Office Pro 2016
    Posts
    21

    Help with multiple dates and values to count occurrences

    Hello,
    I want to count the occurrences that the river crests over a certain height in feet. For example, I want to count a 41ft crest as a single over 40ft river level occurrence. I do not know how to count this crest as a single event. If the river goes over 40ft on 04/17/2022, crests at 41ft on 04/18/2022 and then goes below 40ft on 04/20/2022. This example occurrence over 40ft should count as an above 40ft occurrence and also count as any occurrence over 38ft, 36, 34, etc. I have 15 years of data with levels each hour. Is it possible to count these river levels by occurrence? This is for my own use to track river levels on the farm. I attached a truncated spreadsheet.
    Thank you.
    Last edited by QTS18; 04-19-2022 at 10:47 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help with multiple dates and values to count occurrences

    Your explanation is incomplete...

    Time 1 37
    Time 2 41
    Time 3 37

    Does Time 2 count as >=38 AND as >=40... or just as >=40????
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    07-24-2014
    Location
    Arizona
    MS-Off Ver
    Office Pro 2016
    Posts
    21

    Re: Help with multiple dates and values to count occurrences

    Thank you. Over 40 should count as an over 40ft event as well as over any level less than 40ft.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help with multiple dates and values to count occurrences

    If it counts as both this MIGHT be what you want:

    =SUMPRODUCT(($E$3:$E$48>=40)*($E$4:$E$49<40))

    and similar...

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help with multiple dates and values to count occurrences

    Try this then:

    =SUMPRODUCT(($E$3:$E$48>=I$2)*($E$4:$E$49<I$2))

    however, there is a further complication.. look at the yellow cells. How many >40 should there be?

  6. #6
    Registered User
    Join Date
    07-24-2014
    Location
    Arizona
    MS-Off Ver
    Office Pro 2016
    Posts
    21

    Re: Help with multiple dates and values to count occurrences

    The yellow would count as one over 40, and two over 43, but the 41 at 2100 is not realistic for the river levels. The river rises generally over many hours if not days, then falls at about the same rate.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help with multiple dates and values to count occurrences

    OK.

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

  8. #8
    Registered User
    Join Date
    07-24-2014
    Location
    Arizona
    MS-Off Ver
    Office Pro 2016
    Posts
    21

    Re: Help with multiple dates and values to count occurrences

    Hello again,
    Thank you for the help. One more addition for now. In addition to the number of occurrences, I would like to know if an occurrence occurred between certain dates. For example, a water level above 40ft between April 15th and October 15th of any year. Can you show me how to include this?
    Thank you.

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,885

    Re: Help with multiple dates and values to count occurrences

    This seems to work for dates that fall between April 1 and October 31, inclusive, on the Crests sheet:
    Formula: copy to clipboard
    =SUMPRODUCT(($C$1:$C$44>=H$2)*($C$3:$C$46<H$2)*($C3:$C46<>0)*(MONTH($E2:$E45)>=4)*(MONTH($E2:$E45)<=10))

    If you have hourly or daily data then there may be a way to employ a helper column to find dates between April 15 and October 15 of the years included, however I would need data from April of one year through October of the next to test/demonstrate.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  10. #10
    Registered User
    Join Date
    07-24-2014
    Location
    Arizona
    MS-Off Ver
    Office Pro 2016
    Posts
    21

    Re: Help with multiple dates and values to count occurrences

    Thank you. I think I can work with the whole months rather than a specific date, but I cannot get the month function to discriminate the months. Any idea what is wrong?
    This formula,
    =SUMPRODUCT(($E$3:$E$502853>=I$2)*($E$4:$E$502854<I$2))
    Gives the same output as this formula,
    =SUMPRODUCT(($E$3:$E$502853>=I$2)*($E$4:$E$502854<I$2))*($E3:$E502853<>0)*(MONTH($C3:$C502853)>=4)*(MONTH($C3:$C502853)<=10)

    Also, when I click download on the file you posted, it takes me to the login screen even when I am logged in. It will not allow me to download the file. Any idea why?
    Last edited by AliGW; 04-20-2022 at 11:26 AM. Reason: PLEASE don't quote unnecessarily!

  11. #11
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,885

    Re: Help with multiple dates and values to count occurrences

    If you are sure that some of the flooding is occurring outside of the dates between 1 April and 31 October then I would check to make sure the values in column C are actually dates by widening the column to see that the values right align.
    If that doesn't help, then please upload about 100k rows of the data so that we can troubleshoot.
    I just downloaded the file without problem, so I don't know why the site isn't allowing you to download.

  12. #12
    Registered User
    Join Date
    07-24-2014
    Location
    Arizona
    MS-Off Ver
    Office Pro 2016
    Posts
    21

    Re: Help with multiple dates and values to count occurrences

    It looks ok to me, but I must have something wrong. I attached my file truncated to 30k rows. In this spreadsheet, the over 36ft occurrences in December were my "test" as outside the date range.
    Last edited by QTS18; 04-20-2022 at 11:38 AM.

  13. #13
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,885

    Re: Help with multiple dates and values to count occurrences

    There was an out of place end parenthesis in the month formula (I should have spotted that from post #10).
    Try: =SUMPRODUCT(($E$3:$E$502853>=I$2)*($E$4:$E$502854<I$2)*($E3:$E502853<>0)*(MONTH($C3:$C502853)>=4)*(MONTH($C3:$C502853)<=10))
    Let us know if you have any questions.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help with multiple dates and values to count occurrences

    Thie enables you to select individual start/end dates:

    =IF(SUMPRODUCT((E3:E30000>I7)*(TEXT(C3:C30000,"mmdd")+0>=TEXT(I8,"mmdd")+0)*(TEXT(C3:C30000,"mmdd")+0<=TEXT(I9,"mmdd")+0))>0,"Yes","No")

  15. #15
    Registered User
    Join Date
    07-24-2014
    Location
    Arizona
    MS-Off Ver
    Office Pro 2016
    Posts
    21

    Re: Help with multiple dates and values to count occurrences

    I get the same message as before when I try to download Glenn's file. I am logged in.

    "vBulletin Message
    You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
    You are not logged in. Fill in the form at the bottom of this page and try again.
    You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
    If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
    The administrator may have required you to register before you can view this page."

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help with multiple dates and values to count occurrences

    I've seen this behaviour before. It's an intermittent EF "feature".

    It's a pain in the @ss... no idea what causes it.

    If you open the sheet you posted..

    I7 desired crest height
    I8 desired start date dd/mm/yyyy
    I9 desired end date.

    Then copy/paste formula.

  17. #17
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help with multiple dates and values to count occurrences

    The years are excluded from the calculation. Only dd and mm are considered.

  18. #18
    Registered User
    Join Date
    07-24-2014
    Location
    Arizona
    MS-Off Ver
    Office Pro 2016
    Posts
    21

    Re: Help with multiple dates and values to count occurrences

    Thank you, Glenn. Can I change the yes- no output to a number of times of occurrence?

    Back to my entire spreadsheet, I calculated levels by month and for a reason I cannot figure out, for one particular month I get an occurrence counted at 50, but not for 48 or 49. The data has 48 and 49 occurrences, but the formula does not count them. And for another month, 48 is counted but 44-47 are not counted. Any ideas why?
    Last edited by QTS18; 04-20-2022 at 02:22 PM.

  19. #19
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,885

    Re: Help with multiple dates and values to count occurrences

    The formula is set up to count a crest as being a rise to/above a level and then a fall below the level during a time period. Could it be that while the water rose from below 48 to 50 during the month that it only fell to 49 during that month so that 49 and 48 would not be counted as a crest?

+ 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. Count occurrences and order according to dates
    By ppcash in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-15-2022, 11:49 AM
  2. [SOLVED] How to count occurrences between dates on different columns?
    By jhandatx in forum Excel General
    Replies: 3
    Last Post: 05-13-2021, 03:42 PM
  3. Count unique occurrences between two dates and by location
    By MakoTheDog in forum Excel General
    Replies: 5
    Last Post: 10-12-2020, 03:15 PM
  4. [SOLVED] Count occurrences between dates, containing text string.
    By her.rockstar in forum Excel General
    Replies: 10
    Last Post: 05-09-2018, 11:07 AM
  5. Count occurrences between two dates
    By kettlecorn22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-10-2014, 02:53 PM
  6. Replies: 3
    Last Post: 10-23-2013, 08:42 AM
  7. Count the occurrences of dates in a month against a condition
    By cicilyantony in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-23-2013, 01:26 AM

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