+ Reply to Thread
Results 1 to 13 of 13

Does Excel Formula Exist to Output Same Period Last Year?

  1. #1
    Registered User
    Join Date
    08-03-2018
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5

    Does Excel Formula Exist to Output Same Period Last Year?

    Hi folks,

    New here!

    I'm trying to figure out how to do something using an Excel formula which I would expect is not difficult but cannot find an answer anywhere. I understand DAX formulas exist if you use PowerPivot and I've done that in the past but need to figure out an old school classic formula approach!

    See below example of sales in Q3 last year and current year with totals and YoY growth. At the end of each month you would have to manually update the formula in highlighted cell to reflect the prior year period in order to compare apples to apples. How could I automate this with a formula?

    For example, once you have Sales for Jul/Aug 2018, it would output the revenue for Jul/Aug 2017, so that you can see the respective YoY growth.

    Same Period Last Year.PNG

    Thanks in advance!

    Zahid

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,771

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    Let's assume the data in your screenshot is in row 5, column A onwards.

    In H5:

    =IF(AND(D5>0,E5>0,F5>0),SUM(A5:C5),IF(AND(D5>0,E5>0,F5=0),SUM(A5:B5),IF(D5>0,E5=0,F5=0),A5,"")))
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    Hello and welcome to the forum.

    It'll be hard to give you a working solution just based off of a picture. It would be much better for you to upload the sample workbook.

    That being said, what formula is being used for the Current Period cell (cell G5?)?

    It looks like your dates are actually text values (left justification) so that presents another challenge.

    Try this:

    =INDEX(A5:F5,MATCH(TEXT(DATE(LEFT(INDEX(A4:F4,MATCH(G5,A5:F5,0)),4)-1,RIGHT(INDEX(A4:F4,MATCH(G5,A5:F5,0)),2),1),"yyy-mm"),A4:F4,0))

  4. #4
    Registered User
    Join Date
    08-03-2018
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    Thank you both for your v quick responses. Appreciate it!

    AliGW - I tried your formula but got an error.

    63falcondude - My dates were text and your suggestion worked but when I tried adding data to the 2018-08 column it didn't work as expected. I've since switched to date format and tried to attach file as suggested but the forum won't let me attach as I am new. Would you mind updating the formula to reflect date instead of text format? I'll then troubleshoot from there.

  5. #5
    Registered User
    Join Date
    08-03-2018
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    I think I've managed to attach a file now.
    Attached Files Attached Files

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    Looking at the sample in post #5, try this in H5:

    =INDEX(A5:F5,MATCH(DATE(YEAR(INDEX(A4:F4,MATCH(G5,A5:F5,0)))-1,MONTH(INDEX(A4:F4,MATCH(G5,A5:F5,0))),1),A4:F4,0))

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    Also, I notice there is not a formula in G5. If you want one there too, you can try this:

    =LOOKUP(2,1/(A5:F5<>0),A5:F5)

    This returns the right-most non-zero value from A5:F5.

  8. #8
    Registered User
    Join Date
    08-03-2018
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    Thank you you're so helpful. I've tested and realised I may have not explained clearly my desired outcome. I do not want the totals to reflect the most current month but rather total sales for period to date. So if I have data for Jul/Aug-18, I want the total of that to appear in G5 and the total of Jul/Aug-17 in H5. Does that make sense? Sorry for confusion!

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,771

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    That’s not quite what you showed us at the start, so let’s clarify. When it is June 2018, what do you want it to show for the same period last year? Just June 2017 or the entire quarter?

    What error did you get with my formula? Did you change the cell references?

  10. #10
    Spammer
    Join Date
    01-08-2015
    Location
    Cali, Colombia
    MS-Off Ver
    365
    Posts
    302

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    Hi, to all!

    Why not:
    [H5] : =LOOKUP(2,1/D5:F5,A5:C5)

    If is cumulative, could be:
    [H5] : =SUMIF(D5:F5,">0",A5:C5)

    Blessings!
    Last edited by johnmpl; 08-03-2018 at 11:43 AM.

  11. #11
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    I do not want the totals to reflect the most current month but rather total sales for period to date.
    That's actually easier then.

    Try these:

    G5 =SUM(D5:F5)

    H5 =SUMIF(D5:F5,"<>0",A5:C5)

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,771

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    @JohnMPL - That will only give one month’s amount, not a cumulative total.

  13. #13
    Registered User
    Join Date
    08-03-2018
    Location
    London, England
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5

    Re: Does Excel Formula Exist to Output Same Period Last Year?

    Wow folks I'm learning so fast trying all these formulas thank you so so much!! I'm super happy to say that JohnMPL's cumulative formula did the trick and is exactly what I needed. I actually spent half a day playing with the indirect formula using mapping tables thinking there's no simple way to do this but you proved me wrong!!

    I think I'll coming to this forum quite often!!

    Thanks again!

+ 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: 3
    Last Post: 01-14-2018, 02:47 AM
  2. [SOLVED] Formula who can return correct year for a part I have in stock from period 2008-2016
    By costi_linho12 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-08-2016, 03:24 AM
  3. [SOLVED] Getting wrong output by year formula
    By mso3 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-19-2015, 07:26 AM
  4. [SOLVED] Formula to return month and year based on period.
    By hecgroups in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2015, 03:42 PM
  5. Formula to sum sales over 12 month period not based on calendar year
    By cymraeg in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-02-2014, 12:02 PM
  6. formula to output upcoming quarter end date (for a broken fiscal year)
    By canaille in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-22-2014, 05:01 PM
  7. Replies: 2
    Last Post: 08-06-2011, 11:15 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