+ Reply to Thread
Results 1 to 14 of 14

Month to Date over prior and Week to Date over prior automation

  1. #1
    Registered User
    Join Date
    12-13-2021
    Location
    Chicago, Illinois
    MS-Off Ver
    365
    Posts
    23

    Month to Date over prior and Week to Date over prior automation

    Hello.

    I am currently using formulas to calculate % change for week-to-date / prior week-to-date numbers and month-to-date / prior month-to-date.

    This data is updated daily and requires me to manually adjust the days.

    Is there a way to automatically calculate as new data is added each day? I've attached example file.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-05-2017
    Location
    Brazil
    MS-Off Ver
    Microsoft 365 Version 2404
    Posts
    1,259

    Re: Month to Date over prior and Week to Date over prior automation

    Welcome to the forum.

    I have created dynamic ranges with formula like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The second INDEX portion "INDEX(C$2:C$100,MATCH(MAX($B$2:$B$100),$B$2:$B$100,0)-4)" determines the row the range starts, which corresponds to the MAX date minus 4, (-4).
    Then we can infer that the third INDEX portion "INDEX(C$2:C$100,MATCH(MAX($B$2:$B$100),$B$2:$B$100,0))" determines the row the range ends, i.e., the row with the last date.
    The first INDEX function combines the other two, and the zero as row number establishes that all rows in the range are considered.

    So, for the first SUM, I replace the hard-coded range C25:C29 with this formula: "INDEX(INDEX(C$2:C$100,MATCH(MAX($B$2:$B$100),$B$2:$B$100,0)-4):INDEX(C$2:C$100,MATCH(MAX($B$2:$B$100),$B$2:$B$100,0)),0))"
    For the prior week range, I subtract 5 by changing the -4 to -9 and zero to -5, resulting:
    "INDEX(INDEX(C$2:C$100,MATCH(MAX($B$2:$B$100),$B$2:$B$100,0)-9):INDEX(C$2:C$100,MATCH(MAX($B$2:$B$100),$B$2:$B$100,0)-5),0))"
    I have done it in colum K for the first two cases, so you can compare.

    The problem here is when there are less than 10 rows of data, as the formula will result a VALUE error, but since there must be at least 2 weeks data to compare, I guess that will not be a problem.

    Please run some test and let us know how it goes.
    Attached Files Attached Files

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

    Re: Month to Date over prior and Week to Date over prior automation

    Units Ordered (5 day week?)
    Please Login or Register  to view this content.
    Units Returned
    Please Login or Register  to view this content.
    Ben Van Johnson

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Month to Date over prior and Week to Date over prior automation

    Pl see the file with formulas in Columns J and K.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  5. #5
    Registered User
    Join Date
    12-13-2021
    Location
    Chicago, Illinois
    MS-Off Ver
    365
    Posts
    23

    Re: Month to Date over prior and Week to Date over prior automation

    Hi Estevaoba,

    Thank you for attempting this. The issue here arises when new data is added with each new week. The formula must adjust based on the current day/week and to compare over the prior week as constantly updating.

    For example, I've now added data for 12/13, which means the formula must compare 12/13 over 12/6 and also adjust the MTD to add in the new date. Please see attached.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-13-2021
    Location
    Chicago, Illinois
    MS-Off Ver
    365
    Posts
    23

    Re: Month to Date over prior and Week to Date over prior automation

    Hi kvsrinivasamurthy,

    Same here where it is not considering the new date added for example 12/13. It is not updating with new week over week / month over month calculation.

  7. #7
    Registered User
    Join Date
    12-13-2021
    Location
    Chicago, Illinois
    MS-Off Ver
    365
    Posts
    23

    Re: Month to Date over prior and Week to Date over prior automation

    Sometimes may be 3 or 4 day week depending on holidays and closures. So I would need the formula for week over week to update as each new day is added and compare to prior week. For month over month, the comparison must be for same number of working days.

  8. #8
    Forum Expert
    Join Date
    06-05-2017
    Location
    Brazil
    MS-Off Ver
    Microsoft 365 Version 2404
    Posts
    1,259

    Re: Month to Date over prior and Week to Date over prior automation

    Quote Originally Posted by ZDR23 View Post
    Hi Estevaoba,
    For example, I've now added data for 12/13, which means the formula must compare 12/13 over 12/6 and also adjust the MTD to add in the new date. Please see attached.
    Hello, ZDR23. You're welcome.
    What cells/ranges are to be compared when it is 12/14?

  9. #9
    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
    28,215

    Re: Month to Date over prior and Week to Date over prior automation

    You need to define "Week": is it 5 working days Monday-Friday ? or 7 days "Sunday to Saturday" ??? and what do want to do if (whatever the definition) 2 consecutives weeks [mpnths] differ with number of entries (holidays/missing data) ?

    For month over month, the comparison must be for same number of working days.
    So this does not apply to "Weeks" ?
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  10. #10
    Registered User
    Join Date
    12-13-2021
    Location
    Chicago, Illinois
    MS-Off Ver
    365
    Posts
    23

    Re: Month to Date over prior and Week to Date over prior automation

    Quote Originally Posted by Estevaoba View Post
    Hello, ZDR23. You're welcome.
    What cells/ranges are to be compared when it is 12/14?
    Estevaoba, it would need to compare 12/13 & 12/14 over 12/6 & 12/7. For month over month it would need to include the new day and also an additional day from the previous month.

    I've added weekday, week # and month # to the report which may possibly help.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    12-13-2021
    Location
    Chicago, Illinois
    MS-Off Ver
    365
    Posts
    23

    Re: Month to Date over prior and Week to Date over prior automation

    Quote Originally Posted by JohnTopley View Post
    You need to define "Week": is it 5 working days Monday-Friday ? or 7 days "Sunday to Saturday" ??? and what do want to do if (whatever the definition) 2 consecutives weeks [mpnths] differ with number of entries (holidays/missing data) ?

    So this does not apply to "Weeks" ?
    John, it is 5 working days Monday - Friday.

    For the week over week comparison, I would need the calculation to factor in any holidays (that particular day would not be included in the data). One week may have 5 days of data, while another may have 3 or 4 depending on the given month.

    For the month over month comparison, each month will have a given amount of working days. So, as each day is added, the range is to be adjusted based on that number of days.

  12. #12
    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
    28,215

    Re: Month to Date over prior and Week to Date over prior automation

    See attached

    in L2

    =SUM(OFFSET($C$1,MATCH(MAX($E$2:$E$31),$E$2:$E$31,0),,COUNTIF($E$2:$E$31,MAX($E$2:$E$31))))

    Similar for others

    Change max range to suit

    does NOT solve the issue of year ends e.g month 12/2021 with month 1/2022
    Attached Files Attached Files
    Last edited by JohnTopley; 12-14-2021 at 03:24 PM.

  13. #13
    Registered User
    Join Date
    12-13-2021
    Location
    Chicago, Illinois
    MS-Off Ver
    365
    Posts
    23

    Re: Month to Date over prior and Week to Date over prior automation

    Quote Originally Posted by JohnTopley View Post
    See attached

    in L2

    =SUM(OFFSET($C$1,MATCH(MAX($E$2:$E$31),$E$2:$E$31,0),,COUNTIF($E$2:$E$31,MAX($E$2:$E$31))))

    Similar for others

    Change max range to suit

    does NOT solve the issue of year ends e.g month 12/2021 with month 1/2022

    Thank you John, it appears this logic does work. Is there a way to fix the issue of year ends?

  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
    28,215

    Re: Month to Date over prior and Week to Date over prior automation

    See attached Sheet2 which is a "Trial" based on date to see if it gives correct results: I will do a "year-end" rollover test if this approach is acceptable.

    in I2

    =SUM(OFFSET($C$1,MATCH(TODAY(),$B$2:$B$96,1),,-WEEKDAY(TODAY(),2)))

    For "Week": it starts from Monday until "day" of Today()

    For "Month" starts at first of month(Today()) and counts number work days using NETWORKDAYS.INTL.

    For current/previous months it use "current month" days.

    In November we have a missing date (11/!!/2021) but counts 11 days (blue colouring in column G.

    UPDATE:

    Consider making holidays etc entries with values of zero
    Attached Files Attached Files
    Last edited by JohnTopley; 12-16-2021 at 03:54 AM.

+ 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. [SOLVED] Return Month-on-Month growth using current month-prior month/prior month per country
    By losincog in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2020, 05:37 AM
  2. [SOLVED] date formula that puts the first of the prior month based on which month it is
    By cmorten82 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-08-2015, 05:38 PM
  3. Replies: 1
    Last Post: 02-26-2015, 06:12 PM
  4. Return Friday's Date - Of the Week Prior to selected date
    By JonesZoid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-12-2012, 09:19 AM
  5. Convert date from current month to first day of prior month
    By maacmaac in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-07-2010, 12:23 PM
  6. formula for prior month & year of a month end date.
    By mikeburg in forum Excel General
    Replies: 2
    Last Post: 09-25-2007, 04:01 PM
  7. [SOLVED] Date arithmetic: adding 1 month to prior end of month date
    By manxman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-14-2006, 04:35 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