+ Reply to Thread
Results 1 to 32 of 32

averages of averages for a given day

  1. #1
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    averages of averages for a given day

    Hi.

    I have two columns of data.... column A = dates, column B = money

    I have multiple entries for each date. I am trying to return an average of the average of each day for a long list.

    I have this:

    {=SUMPRODUCT((WEEKDAY($A$2:$A$100,2)=7)*($B$2:$B$100))*(1/COUNTIF(A2:A100,A2:A100))}

    It needs to go through the list of dates and when it finds a sunday, add up and average THAT sunday, then find the next sunday and average it, then average the two Sundays together. I need it to work for the future, I add about 500 rows per month..
    Last edited by S.Peto; 01-03-2017 at 01:46 AM. Reason: clearer

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: averages for a given day

    1 way would be yo add a helper, and test for sunday, then pull that value.

    if that doesnt work, I suggest that you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: averages for a given day

    1 way would be yo add a helper, and test for sunday, then pull that value.

    if that doesnt work, I suggest that you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.

  4. #4
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    sunday 1/1/16 20
    sunday 1/1/16 10
    sunday 1/1/16 30
    monday 1/2/16 5
    ....
    ....
    sunday 1/8/16 30

    outcome 25

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: averages of averages for a given day

    I don't know how you'd do this with a single formula.

    You can get the individual Sunday averages in one step and then get the average of those averages.

    Data Range
    A
    B
    C
    D
    E
    F
    1
    Date
    Weekday
    Value
    Sun AVG
    ------
    Overall AVG
    2
    1/3/2016
    Sun
    20
    37
    35.55
    3
    1/3/2016
    Sun
    54
    4
    1/3/2016
    Sun
    37
    5
    1/4/2016
    Mon
    4
    6
    1/5/2016
    Tue
    76
    7
    1/10/2016
    Sun
    49
    49
    8
    1/11/2016
    Mon
    72
    9
    1/17/2016
    Sun
    47
    41.2
    10
    1/17/2016
    Sun
    26
    11
    1/17/2016
    Sun
    23
    12
    1/17/2016
    Sun
    71
    13
    1/17/2016
    Sun
    39
    14
    1/18/2016
    Mon
    90
    15
    1/24/2016
    Sun
    10
    15
    16
    1/24/2016
    Sun
    20
    17


    This formula entered in D2 and copied down:

    =IFERROR(IF(WEEKDAY(A2)=1,IF(MATCH(A2,A:A,0)=ROW(),AVERAGEIF(A:A,A2,C:C),""),""),"")

    This formula entered in F2:

    =AVERAGE(D:D)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: averages of averages for a given day

    Quote Originally Posted by Tony Valko View Post
    I don't know how you'd do this with a single formula.
    You could do it in a single formula if, and it's a big if, the values to be averaged followed a set pattern.

    For example, the values appear in groups of 2 every 6th row.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    It would be (more) accurate (and mathematically correct) to average Sundays-to date rather than average averages.:

    sunday 1/1/16 20
    sunday 1/1/16 10
    sunday 1/1/16 30
    monday 1/2/16 5
    ....
    ....
    sunday 1/8/16 30

    would give average of 90/4 = 22.5 rather than Average of averages (20+30)/2 =25

  8. #8
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    John, you got me thinking and you are correct, but I was confused. I don't want an average of an average. I need the average of the totals for each Sunday. So in my above example the outcome would be 45.

    Look at the formula my first post... I think it's either correct or close to it, but I can't change it to go beyond 100.

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: averages of averages for a given day

    If you simply want the average for all Sundays...

    Data Range
    A
    B
    C
    1
    Date
    Value
    Sun AVG
    2
    1/3/2016
    20
    36
    3
    1/3/2016
    54
    4
    1/3/2016
    37
    5
    1/4/2016
    4
    6
    1/5/2016
    76
    7
    1/10/2016
    49
    8
    1/11/2016
    72
    9
    1/17/2016
    47
    10
    1/17/2016
    26
    11
    1/17/2016
    23
    12
    1/17/2016
    71
    13
    1/17/2016
    39
    14
    1/18/2016
    90
    15
    1/24/2016
    10
    16
    1/24/2016
    20


    This array formula** entered in C2:

    =AVERAGE(IF(WEEKDAY(A2:A16)=1,B2:B16))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    I need the average of the totals for each Sunday.
    Using data from Tony's last example and changing his AVERAGEIF (post #5) to SUMIF, the Sunday totals will be 111, 49, 206 and 30.

    =IFERROR(IF(WEEKDAY(A2)=1,IF(MATCH(A2,A:A,0)=ROW(),SUMIF(A:A,A2,B:B),""),""),"")

    A moving average of these figures will be 111, 80, 122 and 99

    111/1, 160/2, 366/3 and 396/4

    Is this the required result?
    Attached Files Attached Files

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: averages of averages for a given day

    Quote Originally Posted by S.Peto View Post
    I need the average of the totals for each Sunday.
    I think it's about time that you posted a SMALL sample file that shows us what result you expect.

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: averages of averages for a given day

    As was requested in post #2 lol

  13. #13
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    Ok, here is a sample of data and the expected result. Now I need it to work for 1000s of rows down with a random amount of sunday entries for each date.
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    Use the formula I gave in my example: it will give the average in your posted file.

    See result in column D
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    Quote Originally Posted by JohnTopley View Post
    Using data from Tony's last example and changing his AVERAGEIF (post #5) to SUMIF, the Sunday totals will be 111, 49, 206 and 30.

    =IFERROR(IF(WEEKDAY(A2)=1,IF(MATCH(A2,A:A,0)=ROW(),SUMIF(A:A,A2,B:B),""),""),"")

    A moving average of these figures will be 111, 80, 122 and 99

    111/1, 160/2, 366/3 and 396/4

    Is this the required result?
    John, I want one formula to give me your cell E15 value. It needs to work projected out into blank cells as well.. like A10000 or something.

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: averages of averages for a given day

    Quote Originally Posted by JohnTopley View Post
    Use the formula I gave in my example: it will give the average in your posted file.

    See result in column D
    Sorry for off-topic interjection:

    Although there is no official rule regarding this behavior, we request that wherever possible both the question AND the answer be provided in substantive detail here within the thread. An attached workbook is an excellent aid for posing a question and offering a solution, but solely doing that with no in thread explanation makes it difficult for researchers to understand or consider the Q & A of this thread without downloading what may be a pointless doc to them, if they can do that at all. Doing that also hides the content from search engines so others may never benefit from this.

    I'm sure you understand, and we look forward to seeing you post your formulas/macros in your posts for the searching benefit of all.

    Thanks again for all your hard work here!

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    @Tony,
    The formula and file with solution was provided in a previous post (which I could (should!) have referenced).

    If the OP (or others ???) had looked at my previous reply, he would not have needed to post his last file.
    Last edited by JohnTopley; 01-05-2017 at 04:21 PM.

  18. #18
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: averages of averages for a given day

    Fair enough.

  19. #19
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    Sum ALL Sunday figures and divide by number of unique Sundays.
    Last edited by JohnTopley; 01-05-2017 at 05:07 PM.

  20. #20
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    Try

    =SUMPRODUCT(($B2:$B16)*(WEEKDAY($A2:$A16)=1))/INT((WEEKDAY($A2-1)+$A16-$A2)/7)


    B2:B16 Sales data

    A2:A16 : dates in ascending date order

    For Monday change 1 to 2, Tuesday=3 etc
    Last edited by JohnTopley; 01-05-2017 at 05:27 PM.

  21. #21
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    please forgive me if I am missing something...

    I still do not have a formula that works...

    John, did you miss post #15? I replied to you. Also, =IFERROR(IF(WEEKDAY(A2)=1,IF(MATCH(A2,A:A,0)=ROW(),SUMIF(A:A,A2,B:B),""),""),"") is blank when i put it in my sheet.
    Last edited by S.Peto; 01-05-2017 at 05:29 PM.

  22. #22
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    Try formula in post #20
    Attached Files Attached Files
    Last edited by JohnTopley; 01-05-2017 at 05:33 PM.

  23. #23
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    Quote Originally Posted by JohnTopley View Post
    Try formula in post #20
    I am getting a #div/0 error when i put it into a cell in the sample i provided.

  24. #24
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    You need to adjust the ranges:

    =SUMPRODUCT(($B$2:$B$50)*(WEEKDAY($A$2:$A$50)=1))/INT((WEEKDAY($A2-1)+$A50-$A2)/7)

    Set cell to format NUMBER

  25. #25
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    ok hold on, I changed your formula to extend to row 50 in my sample and it works... however, that formula gets screwed up when i change it to row 1000 for example... I need it to include new items I add and not get screwed up by blank cells not yet filled out

  26. #26
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    Quote Originally Posted by JohnTopley View Post
    You need to adjust the ranges:

    =SUMPRODUCT(($B$2:$B$50)*(WEEKDAY($A$2:$A$50)=1))/INT((WEEKDAY($A2-1)+$A50-$A2)/7)

    Set cell to format NUMBER
    yes, i changed it, but see above... I need it to go far into the future with an unknown amount of rows.

  27. #27
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    Try ....


    =SUMPRODUCT(($B$2:$B$1000)*(WEEKDAY($A$2:$A$1000)=1))/INT((WEEKDAY($A2-1)+LOOKUP(99999,A2:A1000)-$A2)/7)

  28. #28
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    Quote Originally Posted by JohnTopley View Post
    Try ....


    =SUMPRODUCT(($B$2:$B$1000)*(WEEKDAY($A$2:$A$1000)=1))/INT((WEEKDAY($A2-1)+LOOKUP(99999,A2:A1000)-$A2)/7)
    I think you just nailed it. I changed the 1000s to 10000 and did it for each day of the week and it seems like its checking out.

  29. #29
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: averages of averages for a given day

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  30. #30
    Registered User
    Join Date
    11-01-2016
    Location
    AC, NJ
    MS-Off Ver
    2007
    Posts
    24

    Re: averages of averages for a given day

    Something seems possibly wrong....

    Using your formula I get the average of the totals for each sunday. If I go through my real set of data and find a missing sunday date (skipped because there are no entries) and I add the date and put in 0 value, it should bring the average down (1 more sunday to average against), but it does not... unless your formula is already accounting for ALL sundays on it's own regardless of if there is a value there or not...

  31. #31
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,180

    Re: averages of averages for a given day

    Or try this ...

    =SUM(IF((WEEKDAY(A2:A10000)=1)*(A2:A10000<>""),B2:B10000))
    /SUM(IF((WEEKDAY(A2:A10000)=1)*(A2:A10000<>""),1/COUNTIF(A2:A10000,A2:A10000)))

    Enter with Ctrl+Shift+Enter.
    Attached Files Attached Files

  32. #32
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: averages of averages for a given day

    Quote Originally Posted by Phuocam View Post
    Or try this ...

    =SUM(IF((WEEKDAY(A2:A10000)=1)*(A2:A10000<>""),B2:B10000))
    /SUM(IF((WEEKDAY(A2:A10000)=1)*(A2:A10000<>""),1/COUNTIF(A2:A10000,A2:A10000)))

    Enter with Ctrl+Shift+Enter.
    Better if you used dynamic ranges.

    1/COUNTIF(A2:A10000,A2:A10000)

+ 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: 4
    Last Post: 03-13-2015, 05:34 AM
  2. Replies: 9
    Last Post: 05-15-2014, 01:57 PM
  3. Replies: 2
    Last Post: 02-29-2012, 09:34 PM
  4. How to get averages of already calculated averages
    By rosarionyc in forum Excel General
    Replies: 15
    Last Post: 12-29-2010, 03:05 PM
  5. Formula, Averages by name, and differences of averages
    By billyvnilly in forum Excel General
    Replies: 3
    Last Post: 02-24-2010, 05:35 PM
  6. Replies: 1
    Last Post: 05-02-2008, 10:41 AM
  7. [SOLVED] Averages
    By alexfthe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-11-2006, 07:00 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