+ Reply to Thread
Results 1 to 15 of 15

Pulling totals from most current 4 dates that will update as data is added each week

  1. #1
    Registered User
    Join Date
    01-10-2016
    Location
    Houston TX
    MS-Off Ver
    2013
    Posts
    7

    Pulling totals from most current 4 dates that will update as data is added each week

    Hi!
    I am needing some help with a spreadsheet. My spreadsheet has multiple clients and projects. It includes cost totals for each week of the project. I need to pull the last 4 weeks of cost totals for each client for a new tab. The formula needs to be able to update each time someone adds in a new weekly total for a project.

    I'm not sure if that's enough info, but I'm happy to provide more.

    Thanks in advance for your help!

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

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    Will there ALWAYS be at least 4 entries to retrieve?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    01-10-2016
    Location
    Houston TX
    MS-Off Ver
    2013
    Posts
    7

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    To keep it simple, I'm going with "yes".

  4. #4
    Registered User
    Join Date
    01-10-2016
    Location
    Houston TX
    MS-Off Ver
    2013
    Posts
    7

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    And the weeks totals need to be added together. So basically, I need a total of the last 4 weeks for every client.

  5. #5
    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
    52,926

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    Hi, welcome to the forum

    I'm not sure if that's enough info, but I'm happy to provide more.
    It would help a lot if you could 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

  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: Pulling totals from most current 4 dates that will update as data is added each week

    Try something like this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    1
    Client
    ------
    ------
    ------
    ------
    ------
    ------
    ------
    2
    Smith Bros
    51
    41
    12
    82
    23
    94
    3


    =SUM(OFFSET(B2,,COUNT(B2:Z2)-1,,-4))

    The formula returns the sum of 12, 82, 23 and 94. =211

  7. #7
    Registered User
    Join Date
    01-10-2016
    Location
    Houston TX
    MS-Off Ver
    2013
    Posts
    7

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    How's this? {Not sure I'm doing the attaching correctly.}
    Attached Files Attached Files

  8. #8
    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
    52,926

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    Try this...
    =SUMIF(A:A,">="&LARGE(A:A,4),C:C)

  9. #9
    Registered User
    Join Date
    01-10-2016
    Location
    Houston TX
    MS-Off Ver
    2013
    Posts
    7

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    Your formula works well. However, I really need to be able to pull data for one company. I attached an updated version of the spreadsheet that I will be using. You'll see that there are now 2 tabs (this more closely matches how my spreadsheet is setup). My goal is to be able to apply your formula for each company listed on sheet 1. Sheet 2 has consolidated information for multiple companies. For example, I would like to input your formula in B2 of Sheet 1 and only retrieve data for company 'Medical' from Sheet 2.

    I appreciate your help!
    Attached Files Attached Files

  10. #10
    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
    52,926

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    See if this is what you want...
    =SUMIFS(Sheet2!$C:$C,Sheet2!$A:$A,">="&LARGE(Sheet2!$A:$A,4),Sheet2!$B:$B,Sheet1!A2)

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    Another way.

    This must be array-entered in B2 and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you aren’t familiar with array-entered formulae array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Dave

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    Or piggy-backing on Ford's formula ... array-entered also.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    BTW so I could analyze as I was going I reduced the whole column references to 1000 rows.

  13. #13
    Registered User
    Join Date
    01-10-2016
    Location
    Houston TX
    MS-Off Ver
    2013
    Posts
    7

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    I appreciate your help. This formula sums the last 4 entries, regardless of date. I need to sum only entries dated within 4 weeks of the newest date. For instance, in the example spreadsheet I attached, I need a formula that only sums the entries for 'Power' dated from 1/3/2016 to 12/13/2015 (not just the last 4 entries). I've tried using the following formula:

    =SUMIFS(Sheet2!$C:$C,Sheet2!$B:$B,Sheet1!A2,Sheet2!$A:$A,">="&MAX(Sheet2!$A:$A)-28)

    I get the correct results for a couple of customers but not for all. I'm having trouble getting it to work for all Customers listed in column A, at the same time. I'm not sure what the problem is. I attached a newer version of the spreadsheet.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    01-10-2016
    Location
    Houston TX
    MS-Off Ver
    2013
    Posts
    7

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    I'm trying to get the sum for all dates that fall within a 4 week (28 days) range before the newest date, not just the last 4 entries. For instance, in the example spreadsheet I attached, I need a formula that only sums the entries for 'Power' dated from 1/3/2016 to 12/13/2015 (not just the last 4 entries). I've tried using the following formula:

    =SUMIFS(Sheet2!$C:$C,Sheet2!$B:$B,Sheet1!A2,Sheet2!$A:$A,">="&MAX(Sheet2!$A:$A)-28)

    I get the correct results for a couple of customers but not for all. I'm having trouble getting it to work for all Customers listed in column A, at the same time. I'm not sure what the problem is. I attached a newer version of the spreadsheet.
    Attached Files Attached Files

  15. #15
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Pulling totals from most current 4 dates that will update as data is added each week

    Copy paste below and then hold control shift and then hit enter to make it array formula

    =SUMIFS(Sheet2!$C:$C,Sheet2!$B:$B,Sheet1!A2,Sheet2!$A:$A,">="&MAX(IFERROR((Sheet2!B:B=Sheet1!A2)*(Sheet2!A:A),0))-28)
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

+ 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] Set PivotTable Filter to Current Day, Current Week, Current Month, or Current Year
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2014, 08:31 AM
  2. UserForm with that shows Previous Week Data and allows you to update current week
    By hicks1ch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2014, 09:47 AM
  3. [SOLVED] from date data counting how many dates fall in current week
    By KK1234 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 11-03-2013, 08:13 AM
  4. [SOLVED] running totals in Pivot Table - removing a user from the totals for the current week
    By eisenbergg in forum Excel Charting & Pivots
    Replies: 12
    Last Post: 09-08-2013, 04:39 PM
  5. Chart previous week data as grouped and current week as ungrouped
    By r_a_c_a_4_u in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-17-2013, 12:55 PM
  6. [SOLVED] How to find the dates of the current week
    By uvaidya in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-26-2012, 08:47 AM
  7. Replies: 4
    Last Post: 03-21-2011, 05:37 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