+ Reply to Thread
Results 1 to 18 of 18

How to offset an amount to another row below, based on dates?

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    How to offset an amount to another row below, based on dates?

    Hello everyone.

    I have a table that should inform the balance of an account.
    Any row would look like this:
    Period: 1
    Period start: Apr-5-2021
    Period end: Apr-11-2021
    Estimate: $25,000
    Payment: I want those 25,000 from above to be offset to another row
    Balance: whatever


    There is a cell outside the table where I specify the number of days after which the estimate will be paid. I need the value from that cell to be compared to the columns Period start and Period end, it's a range of dates.
    I have this formula which is how I expected to solve it, but it does something different, it brings me the header of the table and it skips some values.
    =OFFSET(E11,ROW(D11)-ROW(D$11)-MATCH(D11+C$4,$D$11:$D$24,1),0)

    Attached is a sample file if my explanation is not clear.

    Thank you very much.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    11-21-2013
    Location
    zimbabwe
    MS-Off Ver
    Excel 2003
    Posts
    124

    Re: How to offset an amount to another row below, based on dates?

    Array formula in F11
    Please Login or Register  to view this content.
    Confirmed with Ctrl+Shift+Enter then copied down

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    Thank you very much, Soledad. That works very well.
    Mind sharing your knowledge a bit? why does the E:E works and not a fixed range like $E$11:$E$24?, how does the SMALL function with the COUNT is working here? I thought that function was useful only for ranking data?
    Thank you, again.

  4. #4
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    Ok, can this be done without an array formula?

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,416

    Re: How to offset an amount to another row below, based on dates?

    Are you still using Excel 2010? What is the problem you perceive with an array formula?

    You don't have to use full column references as long as the first range starts at row 1:

    =IFERROR(INDEX($E$1:$E$500,SMALL(IF(E$11:E11>0,ROW(E$11:E11)),COUNT(1/((C$11:C11-C$11>20)+(D$11:D11-C$11>20))))),0)
    Last edited by AliGW; 04-18-2021 at 02:03 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    Thank you AligW, I'm using Excel 2013, I have to update that field in my profile. The problem I see is that the person who uses the workbook is likely to check the formulas out of curiosity, and they're also likely to freak out if they see their cell change. Also, I had a very reliable alternative formula that seemed to work until I noticed a few problems. The formula was this:
    Please Login or Register  to view this content.
    It worked most of the times, I was using a helper column with the payment dates, but since it was only using the "period end" column to match them, it started to return the wrong result. It worked like 90% of the times, so I supposed a non-array formula could do the job if better designed.

    As for the full column range, I made changes to the formula like this:
    Please Login or Register  to view this content.
    And now it allows me to have a blank cell in period 0 and with the exact range. Still an array though.

    Thank you again, AligW, for your time.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,416

    Re: How to offset an amount to another row below, based on dates?

    I think you are over-thinking this.

    The fact that the original formula does NOT work properly tells us that something slightly more complex is required. Protect your worksheet with a password so that your staff can't accidentally change anything. They shouldn't be fiddling with anything, anyway, and they don't need to know HOW it works.

    If the array formula works and there is no performance degradation (i.e. slow-down), then there is little point in trying to simplify it.

    You need to check this carefully:

    =IFERROR(INDEX($F$12:$F$25,SMALL(IF(F$12:F12>0,ROW(F$12:F12)-ROW(F$12)+1),COUNT(1/((C$12:C12-C$8>C$7)+(D$12:D12-C$8>C$7))))),0)

    The very first array in this type of formula should ALWAYS start at row 1, regardless of the rest of the arrays used, so it should be this:

    =IFERROR(INDEX($F$1:$F$25,SMALL(IF(F$12:F12>0,ROW(F$12:F12)-ROW(F$12)+1),COUNT(1/((C$12:C12-C$8>C$7)+(D$12:D12-C$8>C$7))))),0)
    Last edited by AliGW; 04-18-2021 at 02:54 AM.

  8. #8
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    I think I broke something so I will re-evaluate it with that change. Thank you again.

  9. #9
    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
    43,984

    Re: How to offset an amount to another row below, based on dates?

    Your current formula does not tally with your original sample sheet. Something has changed!! Please repost your file WITH the formula in place.
    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.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  10. #10
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    Hi, Glenn. Thank you for your time.

    I'm attaching the file with the formula applied, just noticed none of the formulas actually do it right because when the payment term is 0, it shouldn't offset any payment, but from day 1 onwards, it should according to the date ranges in columns C and D. Also added another worksheet with my formula which doesn't work in semi-monthly periods. In the end, as long as the payment date is between columns C and D, regardless of the type of period, the invoice total should appear in that row.
    Attached Files Attached Files

  11. #11
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,458

    Re: How to offset an amount to another row below, based on dates?

    Using LOOKUP to track the last "date range+20" that <="period end":

    F12:
    Please Login or Register  to view this content.
    I noticed that the INvoice Total should be equal or smaller than Total cost, a MIN function may help:

    F12:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Quang PT

  12. #12
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    Thank you very much for that formula, bebo021999. Your formula works most of the times, but similar to the index-match method, since it only accounts for the "period end", it returns duplicate invoice totals when dates are semi-monthly, that is:
    1st to 14th day of the month
    15th to last day of the month


    You might be surprised, but when the payment term is 15 days, you can see how it matches the wrong number. The same happens to other payment terms like 16, 17, and when the periods are arranged in a monthly way, it does something similar. I'm not sure why this is, as I'm yet to fully understand your approach, but in the index-match approach, it had something to do with trying to match to the nearest lowest value instead of also accounting for the period start.

    The invoice total is supposed to be always the same as the total cost.

    I'm attaching a file with your formula and with the scenario I just tried to explain above. Please, try to play with the spinner control and see how it works well for most of the payment terms, but then it fails with 15, 16, 17 and others. You may also notice the invoice totals are also different in this scenario, the reason is because the periods are longer and thus they cost more, but in the end, they amount to the same total cost.

    I guess if there's no other choice, an array formula should be used.
    Attached Files Attached Files

  13. #13
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,458

    Re: How to offset an amount to another row below, based on dates?

    OK. So, summing up invoice Totals those due dates fell within Start and end

    F12

    Please Login or Register  to view this content.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    That formula is working so fine it made me realize that the payments can be accumulated in the same period. I wasn't expecting that, but it makes total sense, thank you so much. Is there a way to make it ignore blanks in the period start and end? I have another formula blanking them when they're not required. Or do I need to display them? Either way it's working awesome.
    Last edited by e561414; 04-19-2021 at 02:47 AM. Reason: forgot to tell him it works great

  15. #15
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,458

    Re: How to offset an amount to another row below, based on dates?

    What do you mean "ignore blank"?
    Currently it returnn 0, if expect it to be blank instead:

    =IF(B12="","",SUMPRODUCT(($D$12:$D$26+$C$4>=C12)*($D$12:$D$26+$C$4<=D12)*$E$12:$E$26))

  16. #16
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    Thank you again, bebo021999. What I meant by "ignore blanks" is that in my actual dataset, the dates in columns C and D (period start and period end) are calculated via a formula, and that formula produces a "" for all of the dates that won't be used. These blanks produce a #VALUE! error in the SUMPRODUCT formula. This part of the formula
    Please Login or Register  to view this content.
    Is not ignoring the blanks, the SUMPRODUCT is still using them and produces the error.

    I tried this, but it didn't work.

    =SUMPRODUCT(--($D$12:$D$26+$C$4>=C12),--($D$12:$D$26+$C$4<=D12),($E$12:$E$26))
    Attached Files Attached Files

  17. #17
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,458

    Re: How to offset an amount to another row below, based on dates?

    Try again with SUMIFS:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    06-23-2014
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    22

    Re: How to offset an amount to another row below, based on dates?

    That's PERFECT.

    I learned so much from your examples, bebo021999. I was able to apply it to my actual data set and it's killing it.

    The formula in the first post by Soledad was way outside my comfort zone but I also got to learn a lot from it. Tons of strategies with this little exercise. So thank you everyone, AliW, Glenn, each and all inputs were highly appreciated and educational.

    Have a great day.

    -Edgar

+ 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] Offset dates based on certain criteria
    By tiger10is in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-09-2019, 07:52 AM
  2. Replies: 10
    Last Post: 09-21-2017, 08:03 PM
  3. [SOLVED] Formula between two dates but only show dollar amount if between those dates
    By rhett7660 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-30-2017, 05:31 PM
  4. [SOLVED] Need to find a negative amount and match it to the positve amount based on Acct# and Date
    By sbrandhorst in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-07-2016, 07:49 PM
  5. [SOLVED] Calculating amount of master items based on mixed amount of items
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-21-2014, 11:21 AM
  6. [SOLVED] Sum Amount of Each Year Based on Range of Dates
    By jaclrsen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-29-2012, 08:14 AM
  7. How can I calculate amount of time left based on amount spent?
    By KLD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-23-2006, 11:25 AM

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