Sum of amounts from the previous years

How do i calculate Sum of the value of invoice amounts paid for the FY 3 years prior to the current year.I tried LAG but its not giving me the desired results.
Thanks

Hi
You have to understand how LAG works then you'll be able to do it.
LAG works back looking at a set of sorted data, using the PARTION BY and ORDER BY clauses, then pulls a value from x rows preceding. All the data that you want must be in the worksheet too so you must not be filtering on current year.
Here's what I do:
I take a copy of the worksheet I am working with and look at the data in tabular form. Then I use one or more Group Sorts to pull like items together. These will become my PARTITION BY clauses. Any specific sorting, such as the year come next - these become the ORDER BY clause.
Finally, from where you are in one row you look to see how many rows away is the data that you want and you add that as the final piece of the LAG function.
You then test out the LAG function in the table before moving it into the real worksheet.
Does this help?
Best wishes
Michael

Similar Messages

  • Getting the same day of the week from a previous year in a Power Query calc column

    Hi Power Query users,
    Would like to get your suggestions on this problem. I have a customer that wants to see the previous year's sales for the same day of the week. So today is Friday July 25, 2014. Customer would like to see sales for the closest Friday on the previous year,
    which was Friday July 26, 2013. Next year on Friday July 26, 2015, customer would see the sales for Friday July 25, 2014 and so on. Customer operates 7 days a week, all days of the year including holidays.
    What is the most elegant way to do this? I am assuming the best thing to do is to add this date as a calculated column in the date table, but I am not quite sure the best way to write the formula (including handling of edge cases - leap years, providing
    null when the previous year is not part of the date table, etc).
    I am starting with the
    date dimension as presented by Matt Masson.
    Please help if you have any formula suggestions for this.
    Thanks

    Okay, I'm making a couple of assumptions, so please let me know if these assumptions are incorrect:
    1) Instead of all sales data being in a single column, current year and last year sales are provided in different columns,
    2) The previous year sales column shows the sales occurring on the same
    date as the current year sales (so in your example, 43214 is the sales figure for 6/1/2013.
    If the above assumptions are true, we need to modify how the lookup is done. Let's assume that you created a custom column named SameDayOfWeekLastYear. Create another column called Previous Year Date, using the following function (Date_PreviousYear)
    (date) =>
    let   
        PreviousYearDate = Date.AddYears(date,-1),
        PreviousYearDateAdjusted = if (Date.Day(date)=29 and Date.Month(date) = 2) then
                                       #date(9999,1,1)
                                   else PreviousYearDate
    in
        PreviousYearDateAdjusted
    Incidentally, I created this function the week before your query, for a different purpose. In that case, it was to get the previous year sales occurring on the same
    date as the current year sales. It actually gets to your starting point, but with all the sales data in a single column to start with. However, when the current year is a leap year and you apply the Date.AddYears function, February 29th is calculated
    as February 28th of the previous year. If you then do a lookup for previous year sales, you get February 28th sales looked-up twice (the real Feb 28th and the bogus one resulting from taking February 29th back one year). The PreviousYearDateAdjusted identifier
    puts a truly bogus date instead of a duplicated Feb 28th - one that will always return null when looking up the sales value.
    This new date column will then be used to lookup the row of the previous year sales column that corresponds to the dates in the SameDayOfWeekLastYear column.
    Assuming that the last step in your query is InsertedCustom1, create another custom column (Previous Year Net_Same Day?), which returns the sales on the same day as the current year (the result that you're after). The formula would be:
    LookupValue(InsertedCustom1[Previous Year Net], InsertedCustom1[Previous Year Date], [SameDayOfWeekLastYear])
    where LookupValue is the custom function mentioned previously. After creating this new custom column, you can then remove all of the columns you don't need.
    Hope that the preceding is somewhat clear.

  • User is unable to appoint an employee from the previous tax year

    Hi Experts,
    Can anyone resolve this issue please...
    User is unable to appoint an employee from the previous tax year ( 01/12/2010), Appointment date 01/12/2010 for an employee Please asist...
    Regards
    Sav

    OK .... last user insalled software that was not owned by company. Software removed bug solved.

  • Posting of depreciation in the previous year 2008

    Hi All,
    My client wants to capitalize some expencess in the previous year as assets, and they would like to caliculate depreciation from 01.01.2008 to 31.12.2008, finally they would like to carryforward those amounts to fiscal year 2009.  My client is following jan-dec as fianancial year.
    The assets involved are product licences and will need to be set up  under asset  numbers 99009 onwards. The amounts to be capitalised in 2008 are as follows:
    XYZ               u20AC12,456.89
    As a full years depreciation of 10% of the total costs was taken for 2008, the capitalisation date should be set at 01/01/2008 to allow the figures to be calculated correctly and the correct npv to be carried forward to 2009.
    Please let me know how to do this activity?
    Thanks in advance
    Regards,
    Prasad

    Go to TCode: OAAQ,
    Open Fiscal Year 2008 and post the entries capitalization entry through JV in 2008. Now run AFAB for repeat run for 12th period.
    Howeve above will change the closing balance of 2008 which may be audited and approved.

  • How to calculate the previous year YTD balance in profit & loss statement

    Dear all,
    I would like to seek for advice on how to calculate the previous year YTD (Year to date) balance in profit & loss statement
    For example, if I enter May 2009, the YTD value should be a sum up of value from Jan to May.
    I have tried the current year YTD could be set in column selection dimension "financial period"
    FACT PER( Code = YearFirst(@Per):@Per )  Order By PER.Code Descending
    Then, I tried the previous year YTD in another column using
    FACT PER( Code = YearFirst(@Per-12):@Per-12 )  Order By PER.Code Descending
    But it failed -> Abnormally display three column, while the financial period I enter 200903 in parameter @Per
    Would anyone kindly help me on that?
    Regards,
    Simon Chiu

    Dear Jim,
    Thanks for your reply.
    However, the problems still cannot be solved.
    My expected output is 1 column listing the YTD value from previous year.
    I have tried two times using both the Code = YTD(@Per-12) and Code = YearFirst(@Per)-12:@Per respectively. However, the Excel display various column.
    I am using Financial Period 200903. In the last three column, it display the data in Financial Period 200901, 200902 and 200903 respectively.
    For the current year, the YTD is correct and show 1 column listing the sum of account in the Financial Period 200901, 200902 and 200903
    Would you kindly advice the code setting and how to set? Also, how I can access the syntax builder?
    Regards,
    Simon Chiu

  • How to populate the data or details of only the present year and the previous year with respect to the given RATNG?

    Hi All,
    I have created a form with 5 blocks (namely ENQACMHDR, ENQACMDTL, ENQACEHDR, ENQACEDTL, ENQACSPEC), where i have 8 push buttons (namely ENTER_QUERY, EXEC_QUERY, CLEAR, FIRST, NEXT, PREVIOUS, LAST & EXIT).
    This form is created just for viewing purpose only. So after I execute, all the blocks have been blocked against insert & update.
    I query on 2 fields that is 'ENQNO' and 'RATNG' (Both the fields belong to the block ENQACMDTL).
    When I click on 'EXEC_QUERY' directly, all the data of all the years populates.
    But the user wanted the data to be populated from only the present year and the previous year.
    So , on 'WHERE Clause' of the property_palette of 'ENQACMDTL' block , I put in the following condition:
    SUBSTR(ENQACMDTL.ENQNO, 1,4)=TO_CHAR( ADD_MONTHS(SYSDATE,-12) , 'YYYY') OR SUBSTR(ENQACMDTL.ENQNO, 1,4)=TO_CHAR(SYSDATE, 'YYYY')
    PROPERTY PALETTE (ENQACMDTL block)
    WHERE Clause
    SUBSTR(ENQACMDTL.ENQNO, 1,4)=TO_CHAR( ADD_MONTHS(SYSDATE,-12) , 'YYYY') OR SUBSTR(ENQACMDTL.ENQNO, 1,4)=TO_CHAR(SYSDATE, 'YYYY')
    Now the data of only the present year and the previous year is being populated. Its ok with the field of 'ENQNO'.
    The problem is when i query on field 'RATNG' . 'RATNG' is a Text_item with Number of Items displayed=5. (5 rows)
    The following are 2 columns of a Table (Name=ENQACMDTL) in Database.
    ENQNO
    RATNG
    2013900054
    500KC2
    2013900047
    800KC4
    2013520018
    750KC6
    2012900037
    1000KC2
    2012520109
    500KC2
    2012140019
    750KC6
    2011540036
    500KC2
    2011100030
    1000KC2
    2006100007
    90KD8
    2006750014
    750KC6
    2006900072
    500KC2
    The first 4 numbers of 'ENQNO' denotes the year. There are more than a lakhs of records.
    So when i query on the field 'RATNG',
    Example:For RATNG=500KC2;
    I click on ENTER_QUERY, On the field of 'RATNG' , i put in the value 500KC2 and click on  EXEC_QUERY; Details with respect to 500KC2 is displayed as well as all the other unwanted RATNG like 750KC6, 1000KC2 (which belongs to the ENQNO of the present year and the previous year) also gets displayed.
    I want details of only RATNG (500KC2) to be displayed, but only of the present year and the previous year, that is 2013900054, 2012520109 (ENQNO).
    Other than 500KC2 RATNG, no other RATNG must be displayed.
    The RATNG=500KC2 is also present for ENQNO=2011540036 , 2006900072. But I dont want these to be displayed.
    I want only the data or details of the present year and the previous year to be displayed or populated with respect to the given RATNG.
    Can You Help me or tell me what do i do for this?
    Hope I'm clear with my question!!
    If my question is not clear, let me know plz.
    Thank You.
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    Oracle forms 6i.

    On key-exeqry you have to program.  Delete all other trigger codings for checking your condition.
    It dint work on key-exeqry.
    I tried key-exeqry on form trigger, block (enqacmdtl) and also on field(:enqacmdtl.enqno) , but none of them worked.
    It did not display the message.
    I have a 'PUSH-BUTTON:EXEC_QUERY.
    For EXEC_QUERY, Trigger : WHEN_BUTTON_PRESSED;
    I added the following code:
    if to_number(substr(:enqacmdtl.enqno,1,4))<to_number(to_char(add_months(sysdate,-12),'YYYY')) then
         message('The Rating is not present for the present year and the previous year');message(' ',no_acknowledge);
         raise form_trigger_failure;
    else
         execute_query;
    end if;
    It is working fine and the message is being displayed.
    But again I have a new problem and that is;
    On the field :enqacmdtl.enqno, when i enter the '2013%' and press 'EXEC_QUERY', it works fine.
    but when i enter '2006%' and press 'EXEC_QUERY', it shows the following error
    FRM-50016: Legal characters are 0-9 - +E. It does not display the message also.
    but when i enter the complete number, '2006580002', then it works fine , that is it displays the message (The Rating is not present for the present year and the previous year).
    The problem is because of '%', only when i put in the restricted data (which does not satisfy where condition).
    How do i solve this?
    Thank You Priyasagi.

  • How to display the Previous years

    Hi
      CJE0 - 12KST1A costs:budget/actual/commt/rem.plan/assd
    How to display the previous years budget in above mentioned report. at present the report is showing only cumulative value of previous years,2009 and 2010.....
    My requirement is from 2005 to 2009 i want display the value in this report, please through some light on this.
    Thanks
    S.Murali

    Hi
    But i want check the previous years budget for some number of projects not one by one, because the number of project are more.
    The above mentioned solution is for one by one i can check the pervious years budget. But my requirement is collective.
    Thanks
    S.Murali

  • Depreciation - Post in the Previous Year

    Hi,
    I am trying to post the depreciation for Jan 2010, but the system is giving the error that I need to post in the preious year first.
    However when i am trying to post the depreciation for the previous year, its giving the error that previous year is closed. Can anybody help me how to resolve this issue. Thanks.
    Regards,
    S.Sumana.

    Hello Sumana,
    I have encountered similar issue in one of my clients. What you need to do to remedy the situation is that you need to open the Asset fiscal year in OAAQ and then post depreciation month wise till the current year start. For posting depreciation you also need to open the old accounting period but if there were no asset postings in previuos years then you do not have that risk of anything getting posted in books(which are already closed) in those prior fiscal years. This was from books point of view you maintain status quo.
    Close the previous asset years and posting years once you are done with depreciation posting for a particular year.
    After you come upto date you can run the depreciation normally in current year.
    Regards,
    Vijay

  • Asset You can only post in new  year after closing the previous year

    Hi Experts,
    I am getting below error while running the depriciation:
    You can only post in new  year after closing the previous year.
    Message no. AA687
    Diagnosis
    You want to post in a new fiscal year. However, a posting must have been made in the last period in the previous fiscal year before you can do this.
    Procedure
    Post to the last period in the previous year first.
    Note : I closed FY09, even though there were no assets in it at the time.  The first  asset was capitalized on 12/29/09 (clearly in FY10).  I tried closing FY09 again and got the messege  No year-end close is necessary for company code XXXX .
    Could you please any one help me on this.
    Thanks In Adwance
    Regards,
    Saritha.

    Hi Saritha,
    Please check the following settings:                                                                               
    o Is there one ore more years since the last depr. run?                                                                               
    Solution: in this case an entry must be made into the table TABA. 
                      Note 144441  gives a solution to make a "Dummy-entry".                                                                               
    o If there was never a depreciation run, the there must be 000/0000 in
      TABA and T093D.                                                                               
    Solution: please take the report from the note  Note 144441           
                      and put the values  000/0000 in this fields.                                                                               
    o Do you  have a non-calendar fiscal year (e.g. 2009/10)? In this case
        you should have in the field T093D-AFBLG the year 2010.             
        Solution: Correction with note 26073                              
    regards Bernhard

  • Filter a List for data from the Previous Month

    Hello,
    I have audit data for each month of the year.  At the beginning of one month I pull a report from the previous month.  I would like to have a view in my SharePoint list that shows only the data from the previous month.
    I am not a programmer or developer, so I was wondering if this is possible without out of the box tools.
    Here is what I have done so far:
    Created two calculated columns to find the start and end date of the previous month
              Previous Month Start =DATE(YEAR([Date of Review]),MONTH([Date of Review])-1,1)
              Previous Month End   =DATE(YEAR([Date of Review]),MONTH([Date of Review]),0)
    I have verified these two calculations do show the correct dates. 
    So I can generate the dates, but I don't know how to set up a view filter that will show only data from the previous month. 
    Please help.

    What you need is the calculated column to display the start and the end of the next month, not the previous month. Then you can do a view filter where Start<Today & End>Today.
    EX: If you have a document with date 15-03-2014, you need to save the dates 01-04-2014(start) and 30-04-2014(End).
    Then If Start < [Today] and End > [Today], you can show the document

  • Dep Error:AA687-You can only post in new year after closing the previous year.

    Hi Experts,
    I need solution on error while posting dep. we have new co cd started operative from Jan -14 . So while doing dep posting run we are getting error "AA687-You can only post in new year after closing the previous year".
    I searched and got that Note 144441 need to implement.
    Let me know whether is it fine to go ahead or Is there any alternative solution.
    Also i want to know what need to to be done after implementing this note.
    please reply , its bit urgent.
    Regards
    Atul

    Hi Deepanshu,
    Also the FI period is also closed 2013 so in this case do i need to open the same , correct? for running dep posting along with OAAQ opening for AA.
    Or the note implementation will take care all. instead of running dep , opening closed period.
    pls suggest.
    Regards
    Atul

  • The fiscal year specified differs by more than a year from the fiscal year

    Dear All
    To rectify depreciation posted at development server I run OAGL which reset all depreciation posted (From FY 2008 to 2010), now when I am trying to post depreciation by AFAB for FY 2008 system showing error message
    No posting possible in fiscal year 2008
    Message no. AA688
    Diagnosis
    No posting is possible in the fiscal year 2008 specified. The fiscal year specified differs by more than a year from the fiscal year in which the last postings were performed.
    Procedure
    Correct your fiscal year specifications.
    please advice me what step to be follow
    Regards
    Sekhar

    Hi Sekhar,
    Error AA688 typically occurs in two situations:
    1) A company code did not have any depreciation posted in the previous year. See note 144441.
    2) If in a comany code no depreciation has been posted ever, then it is important to note that the periods of the last depreciation posting  in table TABA and the year and period of the last depreciation posting in table T093D (fields AFBLPE and AFBLGJ) are initial. You can set these fields to 000 / 0000 with the correction report attached in SAP note 26073.
    See if any of this information helps you further.
    Brigitte

  • Every time I launch Firefox 4 it opens 3 or 4 blank windows, no longer opens the tabs from the previous session and does not show my bookmarks sidebar.

    I have to manually close the extra windows and restore the tabs from the previous session, and reopen the sidebar. In disgust I uninstalled Firefox 4 and reinstalled 3.6. Everything works fine in 3.6. Looks to me like Firefox 4 has many major bugs and is not yet ready for prime time. I'll stay with 3.6 for now.

    This can be a problem with the files [http://kb.mozillazine.org/sessionstore.js sessionstore.js] and sessionstore.bak in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder]
    Delete [http://kb.mozillazine.org/sessionstore.js sessionstore.js] and sessionstore.bak in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder]
    * Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    If you see files sessionstore-##.js with a number in the left part of the name like sessionstore-1.js then delete those as well.<br />
    You will have to redo App Tabs and Tab Groups after deleting sessionstore.js.
    See:
    * http://kb.mozillazine.org/Session_Restore

  • How to get a value from the previous element (XSLT/XPATH gurus ahoy!)

    Hi All,
    I am building an RTF template for a "letter of reference"-report. Sometimes there are several rows in the data, that need to be printed as one. This is due to consecutive temporary contracts, which will be printed out as one period of service.
    Here's a simplified data example to illustrate the problem.
    <ROW>
    <START_DATE>01-01-1980</START_DATE>
    <END_DATE>01-01-1988</END_DATE>
    </ROW>
    <ROW>
    <START_DATE>01-01-1988</START_DATE>
    <END_DATE>01-01-1990</END_DATE>
    </ROW>
    <ROW>
    <START_DATE>01-01-2000</START_DATE>
    <END_DATE>01-01-2005</END_DATE>
    </ROW>
    With the data above, I should print two lines:
    01-01-1980 - 01-01-1990
    01-01-2000 - 01-01-2005
    I need to compare START_DATE of an element (except for the first one) with the END_DATE of the previous element, to find out whether to print the END_DATE for that element or not. How can I get that value from the previous element?
    Thanks & Regards, Matilda

    use this to get the following End_date
    <?following-sibling::../END_DATE?>
    Try this
    <?for-each:/ROOT/ROW?>
    ==================
    Current StartDate <?START_DATE?>
    Current End Date <?END_DATE?>
    Next Start Date <?following-sibling::ROW/END_DATE?>
    Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
    ================
    <?end for-each?>
    o/p
    ==================
    Current StartDate 01-01-1980
    Current End Date 01-01-1988
    Next Start Date 01-01-1990
    Previous End Date
    ================
    ==================
    Current StartDate 01-01-1988
    Current End Date 01-01-1990
    Next Start Date 01-01-2005
    Previous End Date 01-01-1988
    ================
    ==================
    Current StartDate 01-01-2000
    Current End Date 01-01-2005
    Next Start Date
    Previous End Date 01

  • I have two iTunes accounts and was wondering if i can merge them together. I've a new macbook pro and haven't plugged my iPhone in it yet in fear of losing my songs from the previous account.

    I have two iTunes accounts and was wondering if i can merge them together. I've a new macbook pro and haven't plugged my iPhone in it yet in fear of losing my songs from the previous account.

    Go to the Music section of your Library (very top-left corner) and see if your songs are there. The "Purchased" playlist may have been deleted or gotten corrupted, but if that happens it's not a big deal because your music should still be in your main Music Library.
    If your music is NOT in the Music section of your Library, then go to the iTunes Store homepage and find the Quick Links list on the right side. At the top of that list, click Purchased and you can redownload all of your previous content that you might have lost.

Maybe you are looking for