+ Reply to Thread
Results 1 to 11 of 11

Adapting ave formulas to changing weeks

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-29-2017
    Location
    UK
    MS-Off Ver
    Pro Plus 2016
    Posts
    301

    Adapting ave formulas to changing weeks

    Hi guys, maybe you'd be able to figure the way of adapting average formulas to existing one's that are used to calculate values based on changing weeks?

    I'm including excel file with all the details explained, but generally its about finding the way how to blend two working formulas together, to get the desired outcome.

    Would it be possible for you to take a look? Thanking in advance!

    https://www.excelforum.com/attachmen...1&d=1507034194
    Attached Files Attached Files

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Adapting ave formulas to changing weeks

    If you add a couple columns to your table between B and C, so that the first week always contains 7 cells
    but still start the day numbering at the appropriate day.
    So in this case you have 2 blank cells representing Monday and Tuesday.

    Then use
    =IFERROR(COUNTIFS(OFFSET($C$5:$I$9,0,(COLUMNS($A1:A1)-1)*7),"Y")/SUM(COUNTIFS(OFFSET($C$5:$I$9,0,(COLUMNS($A1:A1)-1)*7),{"y","n"})),0)
    Attached Files Attached Files

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Adapting ave formulas to changing weeks

    Hi,

    I suggest you build in a formula - perhaps on row 2 which works out which of C2:AD2 are wk1, wk2...etc. and enters "wk1", "wk2" etc in the cells, then use

    Formula: copy to clipboard
    =SUMPRODUCT(($C$2:$AG$2=AH4)*($C$5:$AG$9="y"))/SUMPRODUCT(($C$2:$AG$2=AH4)*($C$5:$AG$9<>""))


    And you can probably simplify your individual row formulae with similar Sumproduct formulae.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    05-29-2017
    Location
    UK
    MS-Off Ver
    Pro Plus 2016
    Posts
    301

    Re: Adapting ave formulas to changing weeks

    Thanks Jonmo1. Not able to add more columns between B and C, as days are changing with every different month selected. So it would never be first 7 cells for 7 days (this also a case in excel copy returned by yourself) But thanks for looking into it!

    @Richard - your suggested option works well! I tested it, by adding WK1, WK2 etc manually. May I please ask for a guide what formula could be applied to cells C2:AG2 to have WK1 WK2 etc adapt to changing weeks, for each different month selected? I'm attaching a file updated, with just those formulas left outstanding, to write off this challenging task...

    Thanking you guys for all of your help, once again!

    https://www.excelforum.com/attachmen...1&d=1507040675
    Attached Files Attached Files

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Adapting ave formulas to changing weeks

    I'm aware of that, that's why the day numbers still begins in the appropriate weekday box. As shown in the example i Posted before.

    Here's a full workup.
    I added columns on both ends of the table to accommodate 6 whole (complete m-s) weeks
    Find the first Monday before the 1st of the month in C4
    =WORKDAY.INTL((2&AH1&AB1)+0,-1,"0111111")
    Then D5 filled to AR5 is just
    =C5+1
    Then just manually put Mon Tue Wed across row 3 (that can be done by just auto filling once you have a couple done by hand)

    The row of Day numbers adjusts automatically when you make your choices of year and month.

    Then your formula for Row 10 is
    =IFERROR(COUNTIFS(OFFSET($C$5:$I$9,0,(COLUMNS($A1:A1)-1)*7),"Y")/SUM(COUNTIFS(OFFSET($C$5:$I$9,0,(COLUMNS($A1:A1)-1)*7),{"y","n"})),0)

    Similar for Rows 5-9 (just focusing on single row, instead of all 5 rows)
    =IFERROR(COUNTIFS(OFFSET($C5:$I5,0,(COLUMNS($A1:A1)-1)*7),"Y")/SUM(COUNTIFS(OFFSET($C5:$I5,0,(COLUMNS($A1:A1)-1)*7),{"y","n"})),0)

    You can probably adjust your conditional formatting to grey out (or whatever) the columns that are not within the specified month
    Attached Files Attached Files

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Adapting ave formulas to changing weeks

    Quote Originally Posted by vill View Post
    @Richard - your suggested option works well! I tested it, by adding WK1, WK2 etc manually. May I please ask for a guide what formula could be applied to cells C2:AG2 to have WK1 WK2 etc adapt to changing weeks, for each different month selected? I'm attaching a file updated, with just those formulas left outstanding, to write off this challenging task...
    Hi,

    Not quite sure where you're up to and I've been out until recently. However in C2 copied across
    Formula: copy to clipboard
    ="WK"&TEXT((INT(COLUMN()-WEEKDAY(B4)+1)/7)+1,"0")
    Last edited by Richard Buttrey; 10-04-2017 at 03:53 AM.

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Adapting ave formulas to changing weeks

    Hang on, that is still the same attachment as before..

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Adapting ave formulas to changing weeks

    Here is the full workup of my suggestion
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,960

    Re: Adapting ave formulas to changing weeks

    row 5 (hidden): to calc week# modified to return 0 for Sat/Sun:
    =IFERROR(IFERROR(WEEKNUM(C$4,2)-WEEKNUM(DATE(YEAR(C$4),MONTH(C$4),1),2)+1,0)*(WEEKDAY(C$4,2)<6),0)
    for weekly averages:
    =AVERAGE(INDEX(WeeklyPercentages,0,AH$4))
    Note that cells AH4:AL4 are numeric not string, custom formatted "WK"#

    Dynamic named range(!),
    WeeklyPercentages='JANUARY (2)'!$AH$6:INDEX('JANUARY (2)'!$AL:$AL,COUNTA('JANUARY (2)'!$B:$B)+3)
    Attached Files Attached Files
    Last edited by protonLeah; 10-04-2017 at 12:27 AM.
    Ben Van Johnson

  10. #10
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    514

    Re: Adapting ave formulas to changing weeks

    Quote Originally Posted by vill View Post
    Hi guys, maybe you'd be able to figure the way of adapting average formulas to existing one's that are used to calculate values based on changing weeks?
    It would have been courteous to mention who developed those existing formulas -- don't you think so?

    Anyway, the solution is pretty simple -- change just four numbers:

    =IFERROR(COUNTIFS(INDEX($C5:$AG5,DAY(WORKDAY.INTL($C$4-1,RIGHT(AH$4,1)-1,"1111110")+1)):INDEX($C9:$AG9,DAY(MIN(WORKDAY.INTL($C$4-1,RIGHT(AH$4,1),"1111110"),EOMONTH($C$4,0)))),"Y")/SUM(COUNTIFS(INDEX($C5:$AG5,DAY(WORKDAY.INTL($C$4-1,RIGHT(AH$4,1)-1,"1111110")+1)):INDEX($C9:$AG9,DAY(MIN(WORKDAY.INTL($C$4-1,RIGHT(AH$4,1),"1111110"),EOMONTH($C$4,0)))),{"y","n"})),0)

  11. #11
    Forum Contributor
    Join Date
    05-29-2017
    Location
    UK
    MS-Off Ver
    Pro Plus 2016
    Posts
    301

    Re: Adapting ave formulas to changing weeks

    @Root_ : that was a formula I was looking for! Replied to that same post you mention, but since it was already marked as SOLVED and there was no replies, thought I lost the chance to be heard there, posted a comment here. It's like you said, "it's plug-n-play -- no helper rows, no changes to your layout, no named ranges" - would be spot on, really needed to make it work in such way, all the way. So thank you for your courage and sharing that lengthy formula :-)

    @Richard - this too what was looking for, and already know where else the same will get applied. So thank you!

    @Jonmo1 & @protonLeah - thank you for your input! I cant tell how many times I was jumping in my chair, saying, 'whoa, just like that?? these guys are genius!!' You really are..

    You're all amazing, thank you so much...

+ 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. Changing Weeks, to Update Values Automatically
    By vill in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-30-2017, 02:03 PM
  2. Replies: 2
    Last Post: 02-14-2017, 09:33 AM
  3. [SOLVED] Add 12 weeks to date to return week number turn over at 52 weeks
    By nigelog in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-01-2017, 05:58 AM
  4. [Additional Question]Formulas for assign monthly values to correspond weeks
    By jackson_hollon in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-12-2014, 02:47 PM
  5. Dividing monthly values into weeks automatically (some months have 5 weeks)
    By massimoo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2012, 03:20 AM
  6. forcast range needs to be changing NOW plus 6 weeks
    By subz-zero in forum Excel General
    Replies: 0
    Last Post: 07-26-2012, 10:10 AM
  7. Replies: 0
    Last Post: 04-15-2009, 05:08 PM

Tags for this Thread

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