+ Reply to Thread
Results 1 to 16 of 16

Calculate average of values greater than zero for ranges of dates

  1. #1
    Registered User
    Join Date
    01-12-2024
    Location
    USA
    MS-Off Ver
    MS 365 version 2312
    Posts
    7

    Calculate average of values greater than zero for ranges of dates

    I created a column with dates of each workday of 2023 and my % appointment arrival rate for each day. For the dates that we were closed for the holiday, I entered 0%. I also created a column for each week of 2023 with the start date of each week. I calculated the average for each week by using this formula:
    =AVERAGEIFS($B$11:$B$270,$A$11:$A$270, ">="&A11, $A$11:$A$270, "<"&D12)

    This calculation worked for the weeks with no holidays. However, for weeks that has any days we were closed for the holiday, I don't want to include those days with 0% in the average. How do I modify the formula above so that only the days >0% are included in the weekly average?

    Thanks.

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,794

    Re: Calculate average of values greater than zero for ranges of dates

    =averageifs($b$11:$b$270,$a$11:$a$270, ">="&a11, $a$11:$a$270, "<"&d12,$b$11:$b$270,">"&0)
    Attached Files Attached Files
    Last edited by etaf; 01-12-2024 at 05:03 PM.
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    01-12-2024
    Location
    USA
    MS-Off Ver
    MS 365 version 2312
    Posts
    7

    Re: Calculate average of values greater than zero for ranges of dates

    etaf,

    Thank you for your quick response. :-) I tried the formula you provided and it's not working correctly. To give you more specific details, I have the following data as example:

    5/29/23 0%
    5/30/23 87%
    5/31/23 91%
    6/1/23 89%
    6/2/23 92%

    When I use my or your formula, I get an average of 87%. However, the way I want it to calculate is to exclude 5/29/23, so that the average is taken from the 4 days and not 5. In this case when I calculate the average of (87+91+89+92)/4, I get 90%.

    Thanks!

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,794

    Re: Calculate average of values greater than zero for ranges of dates

    did you try the formula with that range

    =AVERAGEIFS(B1:B5,A1:A5, ">="&E2, A1:A5, "<="&F2,B1:B5,">"&0)
    Note the > or >= , < or <= - if included the date
    that maybe the difference

    I get 0.89750
    same as
    (87+91+89+92)/4
    same as average B2:B5
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-12-2024
    Location
    USA
    MS-Off Ver
    MS 365 version 2312
    Posts
    7

    Re: Calculate average of values greater than zero for ranges of dates

    I do need to include the date because I have a list of dates for all weekdays and also the first date of each week for the entire year. Please see screenshot attached.
    Attached Images Attached Images

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,794

    Re: Calculate average of values greater than zero for ranges of dates

    images dont help here
    Note: Images are difficult to see , and also requires that I input all the data myself, which means I may make an error, which is very time consuming, and from my point of view less likely to get a response, if a complicated spreadsheet.

    A sample sheet would help here, and possibly will enable a quicker and more accurate solution for you.


    The forum does allow for spreadsheets to be uploaded direct to the forum -

    Please see the Yellow Banner at the top of the page explaining how to attach a sample spreadsheet

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.

    Here are the instructions, found at the top of the page again
    Post a small Excel sheet (not a picture) showing realistic & representative sample data WITHOUT confidential information (10-20 rows, not thousands...) and some manually calculated results. For a new thread (1st post), scroll to Manage Attachments, otherwise scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.

  7. #7
    Registered User
    Join Date
    01-12-2024
    Location
    USA
    MS-Off Ver
    MS 365 version 2312
    Posts
    7

    Re: Calculate average of values greater than zero for ranges of dates

    Please see excel file attached. I have the dates with 0% in red font and I also changed the font to red for the weeks that include those dates with 0%.

    Thanks!
    Attached Files Attached Files

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

    Re: Calculate average of values greater than zero for ranges of dates

    Try:

    =AVERAGEIFS(B:B,A:A,">="&A3,A:A,"<"&A3+7,B:B,">0")
    Attached Files Attached Files
    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

  9. #9
    Registered User
    Join Date
    01-12-2024
    Location
    USA
    MS-Off Ver
    MS 365 version 2312
    Posts
    7

    Re: Calculate average of values greater than zero for ranges of dates

    Hi Glenn,

    Thank you for your response. The % is not correct with the formula you used. As I mentioned previously, for the week of 5/29/23, the average should be 90% and not 87%. I was also getting 87% with my formula because it is including the 0% value for date 5/29/23. Thanks.

  10. #10
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,794

    Re: Calculate average of values greater than zero for ranges of dates

    did you see my post - with your example and the result - post 4 - all in a sample spreadsheet

  11. #11
    Registered User
    Join Date
    01-12-2024
    Location
    USA
    MS-Off Ver
    MS 365 version 2312
    Posts
    7

    Re: Calculate average of values greater than zero for ranges of dates

    Sorry, I did miss the excel attachment. The formula worked! Thanks.

    I have one more formula I need help with. I am trying to count how many cells there are between 70-79%, 80-89%, 90-99% and 100% in the % arrival rate for each weekday, and for each week. For the weekly range, I am using =COUNTIFS($E$11:$E$62,">=90%", $E$11:$E$62,"<=99%") but it is not accurate. I am getting 9 counts but should be 9. Also, I applied conditional formatting for column E so that any cells that have 90-99% would turn green but there are some that didn't. It worked for column E without flaw. I don't know why E32 and E39 did not turn green. I am including the excel file with the calculations. If you can assist with that as well, your help will be greatly appreciated :-)
    Attached Files Attached Files

  12. #12
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,794

    Re: Calculate average of values greater than zero for ranges of dates

    you are only looking at full integers
    BUT you data has decimals

    70-79%, 80-89%, 90-99%
    for example
    will not include 79.001 to 79.9999

    =COUNTIFS($E$11:$E$62,">=90%", $E$11:$E$62,"<=99%") but it is not accurate. I am getting 9 counts but should be 9
    9 =9 ????

    can you put the formulas into the example
    not following the formula with the data
    data starts at row 3- formula start at row 11

    i rearrange the formula to
    =COUNTIFS($E$3:$E$54,">=90%", $E$3:$E$54,"<=99%")
    and got 2

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

    Re: Calculate average of values greater than zero for ranges of dates

    That was because I am a complete idiot.

    =AVERAGEIFS(B:B,A:A,">="&D3,A:A,"<"&D3+7,B:B,">0")
    Attached Files Attached Files

  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 2403
    Posts
    44,150

    Re: Calculate average of values greater than zero for ranges of dates

    If you're only wanting to count % as integers, change the formula in E to:

    =ROUND(AVERAGEIFS(B:B,A:A,">="&D3,A:A,"<"&D3+7,B:B,">0"),2)

    then your countifs should work as planned.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    01-12-2024
    Location
    USA
    MS-Off Ver
    MS 365 version 2312
    Posts
    7

    Re: Calculate average of values greater than zero for ranges of dates

    duh!! Didn't think about that. Thank you so much for all your help. :-)

  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 2403
    Posts
    44,150

    Re: Calculate average of values greater than zero for ranges of dates

    You're welcome. Thanks for letting us know that you got an answer.




    Please take a moment and consider clicking the "Add Reputation" button at the foot of any of the posts of anyone who helped you reach a solution here today.

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

+ 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. Replies: 6
    Last Post: 10-25-2021, 12:40 PM
  2. Replies: 1
    Last Post: 11-19-2015, 10:34 AM
  3. [SOLVED] Calculate years between dates greater than 100
    By Ltat42a in forum Excel General
    Replies: 4
    Last Post: 03-03-2015, 08:38 PM
  4. Calculate weighted average for values between two date ranges.
    By chan069 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-25-2014, 01:12 AM
  5. Replies: 3
    Last Post: 08-27-2014, 04:22 PM
  6. [SOLVED] Calculate Average If Any Cell in Range Greater Than 0
    By jacksonstorms in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-01-2014, 12:10 AM
  7. Replies: 10
    Last Post: 08-08-2009, 06:09 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