Querying the PRIOR YEAR Quarter QTy

Hi Friends and All,
I need your help in querying the PRIOR YEAR Quarter QTy.Please suggest me
Year     Qrt     QTY
1970     Q1     100
1970     Q2     75
1970     Q3     36
1970     Q4     46
1971     Q1     99
1971     Q2     20
1971     Q3     49
1971     Q4     60
1972     Q1     80
1972     Q2     39
1972     Q3     50
1972     Q4     49
2008     Q1     100
2008     Q2     200
2008     Q3     300
2008     Q4     400
2009     Q1     345
2009     Q2     456
2009     Q3     178
suppose if the user select year 2008, then the prvious year 2007 last quarter values should be displayed
Thanks in Adv,
Claoker
Edited by: user12146923 on Nov 4, 2009 10:53 AM

Hi,
Perhaps the best way is a self-join, where you act like one table (c in the example) containes the current year's data, and another table (p) contains the previous year's data, if any.
SELECT       c.year
,       c.qrt
,       c.qty
,       p.year
,       p.qty
FROM          table_x     c
LEFT OUTER JOIN     table_x     p     ON     p.year     = c.year - 1
                            AND     p.qrt     = c.qrt
ORDER BY  c.year
,            q.qrt
;

Similar Messages

  • Is Mountain Lion incompatible with Citrix?  I have had 8 crashes in 3 days which is 7 more than I had in the prior year.

    Is Mountain Lion incompatible with Citrix?  I have had 8 crashes on my MacBook Air in 3 days which is 7 more than I had in the prior year.

    Citrix had updated receiver for mac to 10.6 to support Mountain Lion. Here is the link:
    http://www.citrix.com/English/ss/downloads/details.asp?downloadId=2327673&produc tId=1689163

  • How to use the Time Variants PYTD and Prior Year Annual?

    Hi,
    We have a time dimension which has the generic columns i.e Month, Year.
    We need to calculate the Time variants for the Facts Say Sales. I was able to calculate the Prior Month, Current YTD
    I have some doubts regarding the other variants:
    1. Prior Year : Does this include the Prior Year Annual?
    2. Prior YTD: How to calculate it?
    Somehow I am getting the same results for PYTD and Prior Year.
    The formula used are :
    Prior Year:
    AGO(Sales, Year, 1)
    PYTD:
    AGO(Sales CYTD, Year, 1)
    Has anybody encountered similar issue?

    I assume the Sales measure is a monthly measure. The Prior year calculation as I described will give you the sales for the same month in the previous year when selecting month in your report. When selecting year it will add up all months of the prior year until now and you will indeed see the Prior year YTD.
    If you want to see the total sales for the previous year you have to use the same calculation as 'Prior year' and map it to the year level of your time dimension. This will work as a 'partition by year'.

  • SSRS Matrix report. Variance expression by Month. Need to compare month from prior year to current month of current year VS2010

    Please help.  I have a matrix report.  In the report I have row group  PO Type.  One the Column groups I have a parent group by Fiscal Year, and then a child group by Month.  When I run the report, I get two years of data back broken
    out by month.  Please see below.
    Now here is where I am getting stuck.  I need to take the variance between the current month of the current year, from the same month of the prior year.  So I need to show the difference between Oct , 2014 from Oct, 2013. November, 2014 from November
    2013... etc. etc.
    In the example below, how do I create a column or row showing the variance for Contracts for October 2014.  I need to take the contracts for October 2014 which is 3 and subtract that from October 2013 which is 8.  Any suggestions? How do I do that
    for each month?  Then I need to do it for the quarter... then the year?  But I'll be happy if I can just get the month working first.
    Any help will be appreciated. 
    here is what my rdl file looks like.
    Here is what my report looks like when I render it.

    Hi Adrian_s2012,
    According to your description, you want to compare values for the month of current year with the month of prior year and get the variance. Right?
    In Reporting Services, we don't have any function to get this "Year to Year" Growth. In this scenario, if you data source is a cube, we suggest you use Analysis Services to achieve your requirement. If this data source is just from database, it will be hardly
    to calculate the variance because we need to compare the values within every two different column group and matrix generate adjacent columns one by one. Even we make it by using custom, every time executing the long code when generating result
    in a cell will reduce a lot of performance, we really don't suggest to do that in SSRS. Here is a thread with much easier requirement, please take a reference of that:
    http://social.msdn.microsoft.com/Forums/office/en-US/842e2dcb-d949-4297-9d91-eac989692cb5/difference-between-the-grouped-column?forum=sqlreportingservices
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Need to apply MTD logic for actual and prior year

    Hi Team,
    We are facing an issue with MTD calculation based on formula variables,
    Issue: MTD Only (Actual and Prior Year) – show the same value for MTD. 
    Requirement:
    When the query is run for a selected month, the query should be run for that month based on the Last TECO Date (Input Variable).
    • For example, dashboard is run for January 2014, the calculation of MTD should be based on the Last TECO Date : i.,e if I enter older date/month (not current date)[ 1/20/2014 means it should calculate for 1/1/2014 – 1/31/2014]
    • If the dashboard is run for the current month, the MTD calculation should be on Last TECO Date = 1st day of month – Current Day
    The above same calculation logic should be applicable for MTD prior year: instead of the input variable value, the value for previous year should be considered
    Final Calculation:
    If Last Labour Date is blank, 0, else Last TECO Date – Last Labour Date (by individual line item)
    Here we created two formula variables for last teco date and last labour date.
    Also created 2 Customer Exit variable for MTD Actual calculation.
    We have pulled the formula variable and CE variable into the selection and created a new CKF (Teco date).
    We have done the final calculation on the basis of the ( (labour date ==0)*0 + last teco date-last labour date )for MTD ACTUAL.
    MTD Prior Year-
    when have done calculation on the basis of the( (labour date ==0)*0 + last teco date-last labour date )for MTD Prior year by giving offset -12 to the value.
    Here for MTD Actual and MTD Prior year values are coming same  ,we tried with by doing customer exit variables as well, Still values are coming same.
    please give your valuable inputs/suggestions to proceed for this requirement .

    I assume the Sales measure is a monthly measure. The Prior year calculation as I described will give you the sales for the same month in the previous year when selecting month in your report. When selecting year it will add up all months of the prior year until now and you will indeed see the Prior year YTD.
    If you want to see the total sales for the previous year you have to use the same calculation as 'Prior year' and map it to the year level of your time dimension. This will work as a 'partition by year'.

  • Offset issue for Fiscal Year Quarter

    Dear All,
    There is a requirement to develop a report for balance sheet to compare the fiscal year quarter like if user is going to give input 20143 then comparison quarter is 20142 where I did offset (-1) and if user give input as 20141 then the comparison quarter is 20134 where I am using offset as (-7).
    So I have incorporated both offset in one variable. Now the issue is if I will run for any quarter then it is giving error in the run time. Could anyone suggest that how I could achieve this, whether I have used correct offset interval?
    Query Key Figures Selections:
    Bex Analyzer Selection Error:
    Regards,
    Abhishek Jain

    Hi,
    I wouldn't do it in that way i.e. one column where you count previous quarter for quarters 2 3 4 (offset -1) and another column for counting previous quarter for quarter 1 (offset 7).
    There should be just one column where you count just previous quarter. Use an EXIT to count previous quarter for any value of quarter.
    Regards, Leszek
    something like this can be used:
    WHEN 'ZPREVQUARTER'.
    * QUARTER(1) TYPE C.
    * YEAR(4) TYPE C.
    * have to be defined after DATA: keyword !!!
       IF i_step = 2.
             LOOP AT i_t_var_range INTO l_s_var_range
               WHERE vnam = 'ZCURRENTQUARTER'.
               EXIT.
             ENDLOOP.
             CLEAR: l_s_range.
             YEAR = l_s_var_range-low(4).
             QUARTER = l_s_var_range-low+4(1).
             IF QUARTER = 1.
              YEAR = YEAR - 1.
              QUARTER = '4'.
             ELSE.
              QUARTER = QUARTER - 1.
             ENDIF.
             CONCATENATE YEAR QUARTER INTO l_s_range-low.
             l_s_range-sign = 'I'. "loc_var_range-sign.
             l_s_range-opt = 'EQ'. "loc_var_range-opt.
             APPEND l_s_range TO e_t_range.
          ENDIF.

  • Report with Current and Prior Year

    I'm looking to create a report with fields Report Group, Year, and Actual Dollars.  Where the Year includes the current year and the prior year (NOT user input).  The format would be:
    Report Group | | Year | | Actual Dollars
    Product Revenue | | 2008 | | $100
    Product Revenue | | 2009 | | $200
    etc
    Sounds simple enough but I'm having difficulty getting it to work since I need the Year field in the report (and I'm new to WebI).
    Thanks for your help,
    Dave

    Hi David,
    I'd suggest you use a Query filter (or a report filter) to retrieve only rows that match this criteria on years. Since you need two values, I may have to use the filtering operator 'in list'
    Difference between those two is query filter will only retrieve to values where year = 2008 or 2009 from the datasource (so if you want to change the year values, you will have to refresh document), while report filters are active on the query output (which means that no refresh from the DB is required if you need to change values), which might bring a better experience if you need interactivity in the report. Moreover, if interactivity is important and you are working with WebI XI 3.1 SP2, you can embed these report filters into Input Control, and command the filter from a graphical widget like check boxes, to let user control which years he wants to view/ compare in the table (or chart).
    Hope that helps,
    David.

  • Calendar year quarter

    dear all,
    any function module in bw which returns me the calendar year quarter for 0CALQUART1 and 0CALQUARTER.
    while we on the data subject, what does 0FISCVARNT do? thanks.

    Hello Amit,
    thanks for replying once again.
    i dont want current or previous quarter... nothing wanting to write my own routine, is there any function module in sap which e.g. throws in a date 21/02/2001 and it returns me the quarter.

  • Settlemt-AUCof Prior Year Acqn to G/L Account in current yr Possible or not

    Hi Gurus,
    My client is following calendar year and has already closed the fiscal year for Asset Accounting.Later on they found that there is some amount lying in one AUC in the prior year-2007 which has to be settled in current year to a G/L Account Expense in the current year-2008.
    When I try settling the same via AIBU, the system is giving an error message as below:-
    Settlement of Old Asset Data to Receiver Type G/L Not Allowed
    Message no. AW607
    Diagnosis
    You tried to settle values from the previous year to a receiver other than an asset.  This procedure is not supported by the system.
    Procedure
    Check your distribution rules and change the receiver.
    Is there any way by which I can settle the AUC to G/L Account in the year 2008 since the accounts are already finalised.
    Suitable points will be awarded .
    Regards
    Gopal

    Dear Friends,
    Ask ur friend to pass the following entry thru f-02 in the current year:-
    Expense or Prior Period Expense    dr
       To AUC (posting key 75 and Tran Type 160)
    I hope this will work

  • Internal Order Settlement Reversal Prior Year KO88

    Hi,
    I am on ECC 6.   We have been asked if it is possible to reverse prior year settlements for internal orders in the current year and period.                                                                The current year  reversals are not the issue. These orders settlements in need of revision were made in the prior year and the periods are all closed and not to be opened as the financials are complete for that year.
    Presently, there are two steps :  1) Reverse the current year periods and resettle using revised settlement rules.in the current year open period.                                                                                2) Prior year corrections made through a manual journal entry also posted in the current period. 
    Goal is to eliminate the manaul entry for prior year correction due to revised order settlement rules  
    Any thoughts on this issue would be appreciated.

    The only reason to resettle the orders is that the "settlement rules" were revised in the current fiscal year .  In the current fiscal year , the settlements for each settled period (closed period) are reversed and then resettled in the current  open period using the revised settlement rules. However, the issue involves these same orders had costs in the previous fiscal year and were settled originally in that previous fiscal year with the old settlement rules. This is a closed fiscal year and all periods are closed.  
    Any thoughts on a system approach to effect the settlement rule change crossing two fiscal years rather than manual entries for prior fiscal year settlement rule impact as a  two step process the first step being the current fiscal year resettlements and the second step the manual entry for previous year impact ?

  • Business Area Clearing considering Prior year transactions why?

    HI SAP Experts,
    I have a problem in Business Area Clearing with one of our client. After running Business Area clearing in F.5E. I went and checked the log in F.5F.
    I found that the system is considering Prior Year transactions also, though they run the Business Area clearing every month.
    What could be the problem? Where it went wrong?
    Can anyone guide me on this!!
    Thanks & Regards
    Omprakash RA

    HI
    Thanks for the prompt reply.
    But what I meant to say here is it is considering all the prior year transactions for the clearing.
    Hope I'm clear now.
    Thanks
    Omprakash RA

  • Suppressing a prior Year Month Column on Cross Tab Report

    I have two cross tab report in the footer that compares orders booked against what was shipped by month.  I need to suppress the columns (Month) for the prior year but keep the Totals.
    I have a pdf of the report

    Try to add a formula as a column in the crosstab instead of a field. Create a formula like this
    if year()=year(currentdate)-1 then
    year()
    else
    month()
    This works only for two years of data, means you need to have the record selection formula like this
    year()>=year(currentdate)-1 and year()=year(currentdate)
    Regards,
    Raghavendra

  • Scope statement for Change From Prior Year

    Hello All,
    I have to create Current Year, Prior year  and change from Prior year for all the measures. I was able to creat current Year and Prior Year calcuation with scope statemnet. But I could not do the same for Change from Prior year.  I am getting 0 for
    all the months.
    Here is what i have:
    SCOPE([LABEL].[LABEL].&[ChangeFromPY])
    THIS=
    AGGREGATE(
    [DATE DT].[Date_Hierarchy].CURRENTMEMBER,
    [LABEL].[LABEL].&[Current Year]
    AGGREGATE(
    PARALLELPERIOD
    [DATE DT].[Date_Hierarchy].[Year], 1, [DATE DT].[Date_Hierarchy].CURRENTMEMBER),
    [LABEL].[LABEL].&[Prior Year]

    Hi Om25,
    According to your description, the Prior year calculation works on Excel, however, it not works when creating dashborad in performance Point, right? In this case, you can create separate measures for Prior Year in Cube, and use it in performance Point directly.
    Here is a link that might helpful for you, please see:
    http://www.bidn.com/blogs/cprice1979/ssas/2473/fun-with-mdx-ndash-part-3-ytd-and-prior-ytd-calculations
    Regards,
    Charlie Liao
    TechNet Community Support

  • Enable fiscal year/quarter selection in a query

    Hello all,
    I want to have an characteristic fiscal year/quarter similar to fiscal year/period (0FISCPER) in my query. Unfortunately I can not find such a characteristic in the time infoObjects in my cube and in the administrator workbench.
    Our Fiscal year starts in July. So the first quarter is July - September. The BW release is 3.5.
    How canI enable a fiscal yearquarter selection in my query?
    Any ideas would be great.
    Thanks upfront and Best regards,
    Stefanos from Munich/Bavaria/Germany

    Stefanos ...
    A couple of options for the same :
    1. Have 0FISCPER in your cube and map the same to the custom characteristic in the update rules.
    2. Have the custom characteristic in the cube in a separate dimension
    3. If you have the same in the cube - have a variable against that and execute your query...
    By doing the above you can get the same in the query.
    Arun
    Assign points if useful

  • Prior Month/Quarter/year Measure

    Hi Gurus,
    I have 3 drop downs year,quarter and month in my report.
    Now in my report 2 measures are shown.Current Period and Prior Period.
    Now if i select 2011 as year in drop down then current period will be of 2011 and Prior Period will be of 2010.Same is the case for Quarter and Month.
    For this i have created 3 measures for AGO.(AGO Year,AGO Quarter and AGO Month).
    I have written case statement for the Prior Period Column in Answers so that if the user selects Year in the drop down then AGO year will be shown ,if user selects Quarter then AGO Quarter will be shown.
    Now i m getting error in the report
    A general error has occurred. [nQSError: 22036] Level in AGO function (Month) must be a rollup of (or equivalent to) the measure level (Year). (HY000)
    Please help me in this regard

    Fiscal Sales :=
    SUM ( 'LG_ACTUAL_VS_BUDGET_V'[Dollar Value] )
    Prior Year Fiscal Sales :=
    CALCULATE (
        [Fiscal Sales],
        FILTER (
            ALL ( 'LG_ACTUAL_VS_BUDGET_V' ),
            'LG_ACTUAL_VS_BUDGET_V'[Fiscal Year]
                = MAX ( 'LG_ACTUAL_VS_BUDGET_V'[Fiscal Year]
    ) - 1
    The second (and following) arguments to CALCULATE() have to be filter expressions or table expressions.
    In this case we are using the table expression, FILTER() - confusing, that.
    ALL( 'LG_ACTUAL_VS_BUDGET_V' ) means that we'll be applying a filter to every value in LG_ACTUAL_VS_BUDGET_V
    and returning a table that is a subset of that table based on the second argument to FILTER(). This is necessary, because your row filter (in this case the [Fiscal Year] that will be in the pivot table) would otherwise eliminate values for other years from
    the filter context.
    The second argument to our FILTER():
           'LG_ACTUAL_VS_BUDGET_V'[Fiscal
    Year]
                = MAX ( 'LG_ACTUAL_VS_BUDGET_V'[Fiscal Year]
    ) - 1
    This compares the values in the column [Fiscal Year] to MAX ( 'LG_ACTUAL_VS_BUDGET_V'[Fiscal
    Year] ) - 1. The MAX() function respects your row filter (remember, the [Fiscal Year] in the pivot table), and is necessary because we need to convert the values in that column to a single scalar value. We then subtract one.
    Thus FILTER() is returning a table of all values from LG_ACTUAL_VS_BUDGET_V where
    the fiscal year is the prior fiscal year compared to the current row context. This table is being used as the second argument to CALCULATE().
    CALCULATE() then determines the value of [Fiscal Sales] in the context of that table.
    I hope this helps a bit with your understanding of what's going on and how to properly
    use CALCULATE().

Maybe you are looking for

  • I am trying to install Appletv with an iPad2 and cannot get Homesharing to work

    I am trying to install Appletv with an iPad2 and cannot get Homesharing to work

  • Photos in albums missing

    The photos in my albums show the black background with an "!" when they are clicked. I have rebuilt the Library with option/command keys pressed when loading iPhoto and selected the first three items in the menu. How can I get these photos to show wh

  • Recording radio programs

    Is there a way to record live radio (not podcasts) onto the touch? There are some shows that run in the middle of the night that I would like to record to listen to at a later time. Thanks for your help.

  • Circle with a Slash Through it and Non-Mounting Hard Drive

    Hello, So I have a Macbook Pro (Early 2011) and the other day it was installing some update. It turned off, so I went upstairs to plug it in but once I powered it on and logged in it just shows a circle with a slash on it. The guest user account work

  • VA01 F4 selection screen do not need CR document type in list of doc.type

    Hi My requirement is following step 1: execute T.code VA01 step 2: Press F4 on Order type: you will get list of all Order doument type, (like, OR,KE,KB,KR,CR,DR and etc..) step 3: Now i don't want CR document type in list of order document type throu