To compare current year with prior year

Hi
Please can you help me  to create proper sql to get the output like same as I attached herewith . it would be appreciate
polachan

You can do it in multiple ways
1.
SELECT COALESCE(t1.Company,t2.Company) AS Company,
COALESCE(t1.Sales2015,0) AS CurrentYearSales,
COALESCE(t2.Sales2014,0) AS PriorYearSales
FROM Sales2015 t1
FULL JOIN Sales2014 t2
On t2.Company = t1.Company
2.
SELECT Company,
MAX(CASE WHEN YearVal = 2015 THEN Sales ELSE 0 END) AS CurrentYearSales,
MAX(CASE WHEN YearVal = 2014 THEN Sales ELSE 0 END) AS PriorYearSales
FROM
SELECT Company,Sales2015 AS Sales,2015 AS YearVal
FROM Sales2015
UNION ALL
SELECT Company,Sales2014 AS Sales,2014
FROM Sales2014
)t
GROUP BY Company
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How to compare current date with past date

    Sample code for comparing current date with past date
    i dont want to Calender.set method to compare it.
    How can i do it?

    PLEASE stay with ONE thread:
    http://forum.java.sun.com/thread.jspa?threadID=5143991&tstart=0

  • Line Chart to Compare Current Year vs Last Year

    I am on BI 7 SP9. I need to create a line chart that shows 2 lines to compare  revenue for the current year against last year. The first line should show the revenue for the current year. The second line should show the revenue for last year. In my BEx query, I have the fiscal period values in the row and the revenue key figure in the column. Questions:
    1. How can I show 2 lines in the chart to compare revenue for the current year vs last year?
    2. There are 2 variables for the fiscal period - one for current year and one for last year. The user can enter any value range in the fiscal period variables at query runtime, but the fiscal periods for each of the 2 years must be the same. This means the number of fiscal periods that appear in the query result rows will vary (e.g.. 3 periods for a quarter or 12 periods for a full year). The user has to enter the same fiscal periods for the current year and last year variables. How can I determine the fiscal period values to plot in the line chart for the current year and then last year when the number of rows in the query results will fluctuate?
    The legend at the bottom of the chart should show JAN, FEB, MAR...DEC instead of the fiscal period values like 001/2007, 002/2007. Is there an exit I have to change to get this to work?
    Thanks for any help you can give!

    You can do it in multiple ways
    1.
    SELECT COALESCE(t1.Company,t2.Company) AS Company,
    COALESCE(t1.Sales2015,0) AS CurrentYearSales,
    COALESCE(t2.Sales2014,0) AS PriorYearSales
    FROM Sales2015 t1
    FULL JOIN Sales2014 t2
    On t2.Company = t1.Company
    2.
    SELECT Company,
    MAX(CASE WHEN YearVal = 2015 THEN Sales ELSE 0 END) AS CurrentYearSales,
    MAX(CASE WHEN YearVal = 2014 THEN Sales ELSE 0 END) AS PriorYearSales
    FROM
    SELECT Company,Sales2015 AS Sales,2015 AS YearVal
    FROM Sales2015
    UNION ALL
    SELECT Company,Sales2014 AS Sales,2014
    FROM Sales2014
    )t
    GROUP BY Company
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Compare - Current Data with Perious Data.

    Experts,
    We have created default report like below
    Date - Company - Product - SCode - Amt Spent - Net Amt - Calls
    12/12/2010 C1 P1 Code1 1000 1500 15
    13/12/2010 C2 P4 Code2 1500 1200 10
    12/12/2009 C1 P3 Code3 2000 1700 25
    11/12/2010 C3 P1 Code4 3000 1600 10
    11/11/2009 C2 P2 Code5 5000 3000 30
    Grand Total 12000 9000 90
    Here we are using Column selector for Date column to change the report from Date to Week (or) Month (or) Quarter (or) Year.
    My Questions
    1. I want to compare Default Date report with Perious Date, Last month Date and Last Year Date.
    2. If I select Month from Column Selector then I want to compare Month report with Last Month, Last year Month or Perious of Last year month.
    3. If I select Year from Column Selector then I want to compare Year report with Last year, or Perious of Last year and so on.
    Please help me, how can we achive the above task.
    Thanks in Advance.
    Balaa...

    Hello,
    First you have to define the new measures for last month, last year and so on. You can refer to this link:
    http://www.rittmanmead.com/2007/04/obi-ee-time-dimensions-and-time-series-calculations/
    After that, what you can do is instead of using a "Column Selector" you should use "View Selector". You can create different views, one for month, other for Year and include them into a "View Selector".
    After that you can add it in "Compound Layout".
    Regards,
    JorgeRS.

  • Compare current value with previous value

    Hello,
    I would like to compare the current value with the previous value of the current value.
    How can I solve this problem?
    Maurits

    Hi,
    after going through the basics course you surely can understand that example:
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Compare current date with dat from db by JSTL

    hi all
    I use
    <tr><c:forEach items="${allFound}" var="found" varStatus="myRow">
    <td><c:out value="${found.submitDate}"/></td>
    </tr>
    </c:forEach>
    to past some value out of db
    how can I compare this submitDate with Current Date by JSTL
    Thank you!

    Whether or not you can compare it depends on what the type of "${found.submitDate} is coming from the Database.
    I am going to presume it is a java.util.Date.
    You can get the current date like this
    <jsp:useBean id="now" class="java.util.Date"/>
    You can then compare them using an EL expression:
    {code}
    <c:if test="${submitDate < now}">
    We have not yet reached the submit date.
    </c:if>{code}
    EL uses the java compareTo methods, so both of your objects +must+ be of the same class in order for this comparision to work.
    If you get back a String from the database, you would have to use <fmt:parseDate> to get a java date.
    If you get back a java.sql.Date from the database, it would get trickier. The hack would be to go java.sql.Date -> String -> java.util.Date using <fmt:formatDate> and <fmt:parseDate>
    Hope this helps,
    evnafets

  • How to compare current time with any particular time?

    Hi All,
    Problem:
    I have a form which accept data from user but i want that user can enter data only before 4 in the evening after that no data will be accepted and user get any message. Now the problem is I want to compare the current time with 4 o clock or 16:00:00 but i dont know how to check whether the current time is greater or lesser than 4. Till now my code are like this: if(tt.equals("16:00:00")){}else{}
    where tt is current time. but this is not the feasible solution for my second clause.
    Any kind of help will greatly appreciate.
    Thanks

    One more thing:
    I find timestamp class quite helpful in my case but i
    dont know how to implement the before() method
    of this class.
    Any idea.* You wouldn't implement before(). You'd just use it. It's already implemented for you.
    * before() doesn't just compare the hour of the day. It compare two date & time objects to see which one is greater--that is, it effectively looks at all the fields, not just HOUR.
    * You don't need Timestamp if you're not dealing with a database.

  • SSRS Variance expression problem. Create a Variance expression. Compare current month with same month from previous year.

    Hello,
    I am using VS2010 shell.  I have a matrix report where I have a row group by Year.  Then I have a column group by Month. 
    When I run the report, I get 2013 data on top of 2014 data.  Now I need to create a variance by year for each month.
    So in the example below, I need to create an expression that will pull the variance for Oct 01... subtracting 2013 from 2014 for the months.  So I need to Subtract 8,222 - 4290.  I have no clue.
    Here is what my rdl looks like.
    Thank you for your help. 

    Hi Adrian,
    If I understand correctly, you want to calculate the difference order between 2013 and 2014 for every month. And there are only two years in the FISCAL_YEAR field.
    If in this scenario, we can simply use the following expression to achieve your requirement:
    =first(Fields!ORDER.Value)-last(Fields!ORDER.Value)
    The following screenshot is for your reference:
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • 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

  • How to compare a Date data with Current Year and Period Member on FIX

    Hi experts,
    I have a Project dim that each member is a Project (P01, P02...)
    and Account dim that stores information of the each Project (Name, Start date, Finished Date...)
    Finished Date member is in Date data type
    So how can write a IF condition below in order to compare Project Finished Date with Current Year and Period members on FIX
    FIX (@Descendants(Projects), Descendants(All Year), Descendants("Year Total")...)
    IF (@CURRMBR(Period)->@CURRMBR(Year) < Project->FinishedDate)
    Do something...
    Else
    Do something
    Please help me on this. Sorry for my bad grammar. Please ask if there is anything unclear
    Many thanks,
    Huy Van.
    Edited by: Huy Van on Jan 29, 2013 1:14 AM
    Edited by: Huy Van on Jan 29, 2013 2:24 AM
    Edited by: Huy Van on Jan 29, 2013 2:25 AM
    Edited by: Huy Van on Jan 29, 2013 6:04 PM

    Here is what I have done. Post for whom may concern later
    VAR FM; /* Finished Month of Project*/
    VAR FY; /* Finished Year of Project */
    VAR CM; /* Capture Current Month on FIX statments */
    VAR CY; /* Capture Current Year on FIX statments*/
    FIX ( @RELATIVE( "Year", 0), @RELATIVE( "Period", 0), @IDescendants( "Base Projects")....)
    FY = @ROUND( "TGHT"->"NA Contract"->"FY06"->"NA Period" / 10000, 0);
    FM = @MOD( @ROUND( "TGHT"->"NA Contract"->"FY06"->"NA Period" / 100, 0), 100);
    /* For FY13 return 13... */
    CY = @JgetDoubleFromString( @CONCATENATE( "20", @SUBSTRING( @NAME( @CURRMBRRANGE( Year, Lev, 0, 0, 0)), 2)));
    /* Set CM value based on currrent Period On FIX statement */
    IF ( @ISMBR( "Jan"))
    CM = 1;
    ELSEIF ( @ISMBR( "Feb"))
    CM = 2;
    ELSEIF ( @ISMBR( "Dec"))
    CM = 12;
    ENDIF
    IF ( CY < FY OR ( CY == FY AND CM < FM))
    Do something...
    ELSE
    Do something...
    ENDIF
    ENDFIX
    Edited by: Huy Van on Feb 19, 2013 11:10 PM
    Edited by: Huy Van on Feb 20, 2013 7:46 PM

  • NVision prior year totals are overwriting with current year

    Hi All,
    I have created an nVision report with two columns, one is for Current year(timespan-YTD) expense totals and other one is for Prev Year(timespan-Prev_Year) totals and row level i have all Expenditure accounts from Account Tree.
    When I run the report, Current Year and Prev Year coulumns are displaing same totals, when I ran the SQL trace, i found that Prev Year, column sql was running two times, one is for prev year and otherone is current year and second sql was overwriting with current year totals.
    When I looked into timespans for PREV_YEAR, I saw that "End Period Type" was set to "Relative to Current Period", when I swich to"Absoluate Period" then Prev Year column was showing Prev Year results.
    But switching Period type to : Absolute is wrong,when comparing the current year with Prev year with As of Date.
    Any thoughts on above issue.
    Thanks,
    Venky

    Dear Rachana
    The long text of error AA669 is very clear about the root cause of the
    error.
    The idea behind the message: it is not allowed to close first general
    ledger before subleger. This leads to inconsistencies. It is common
    accounting principle to always close the subledgers first and only
    then close the general ledger (FI-GL).
    The solution is: re-open fiscal year in FI-GL (txn OB52) and follow the
    steps from note 619969.
    o  RAAFAR00
    o  RAPOST2000
    o  RAPERB2000
    o  RAJABS00
    If it is not possible to open the fiscal year because audit has already
    been completed: workaround (which is not quite correct from the legal
    point of view) is the report RACORR20_A from note 29694.
    Best Regards,
    Blaz

  • Reporting with Time Variance (previous year vs current year)

    Good day all.
    I would like to ask for advice and help in terms of best way to make this report work:
    Let's say I need to show the % variance between the Total Operating Costs per Gross sqft over different times periods (Previous year to Current Year). The trick is that data must be compared to the same data in the previous year, i.e. if we are in June of current fiscal year, the comparison must be between Oct-June of current fiscal year to Oct-June of previous fiscal year, not the full previous year. The report formula itself would be:
    ([TCO Exp/GSF PY] - [TCO Exp/GSF CY]) / [TCO Exp/GSF PY] * 100
    My guess, I could define a static variable Current Year which developers would have to be changed every year. And then create logical columns: TCO Exp PY (where year=Current Year-1)...while writing this, I realized I'm wrong and there must be a more efficient way to do this. UPD: I've also thought about time-series function AGO, but I'm currently testing it, and I'm not happy with its performance...
    Thank you in advance...
    Message was edited by:
    wildmight

    Hi Wildmight,
    The current value will be the value you will select from the table like you normally would do. These would be values per month if I am correct. Next to the column with the current value, you create an additional column with the AGO function in it.
    Now you will have the current value and next to it the value of the required period ago. You won't need any static variables.
    Let me give you an example for the last three months.
    Period CY PY
    jan-08 50 30
    dec-07 40 20
    nov-07 45 25
    In this case the value 20 corresponds to the period dec-06.
    I hope I made myself clear.
    Good Luck,
    Daan Bakboord

  • Standard Cost Estimate Report Comparing Current vs Previous Year

    Hi Everyone,
    Is there a standard SAP report that would provide materials with previous and current year standard cost estimates as found within the Costing 2 view of the material master?
    Thanks,
    Pete

    Hi,
    You need to look into periodic reports. Here is the best one to provide the copmarision between two period -
    S_ALR_87099932.
    Go into the report & select the costing runs taken in two diffrent periods. You will get all the required results of prices for two periods/costing runs.
    Regards,
    Amol

  • How  to modified automatic batch number with plant and current year details

    hi all,
            i want tomodify automatic batch number with plant and current year details. if any one understand plz explain.
    thanks,
    radhakrishna.

    Hi,
    I am not clear what is u r requirement exactly?
    I  mean you don't want automatic batch no or modify the batch no.  with plant means and Current year details means.  Can give details more
    Regards
    Ganesh

  • Problem with the text from previous year in current year appraisal (PPR)

    Hi Gurus,
    I have some problem with the text from the PPR of the previous year in the PPR current year.
    The text from the previous year have not the same displaying in the tab "previous year" of  the current year PPR.
    EXAMPLE :
    this is write in the PPR of year 2009 in Individual Targets without Incentives (tab My S-imple) :
    -Aufrechterhaltung der MA motivation, in dieser Zeit der Neuorientierung.
    -G1 Unterstüzung
    -Fachübergreifende Teamarbeit ausbauen
    Gefährdungsbeurteilung weiter führen
    -tragen von PSA einfordern
    -VI Opt.(Intervalle)
    -Azubi und Praktikanten AUsbildung unterstüzen
    and this is what I have in the PPR of 2010 in Individual Targets without Incentives (tab Previous Year's Targets):
    -Aufrechterhaltung der MA motivation, in dieser Zeit der-Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    -Aufrechterhaltung der MA motivation, in dieser Zeit der
    there is the error, all the end of the text isn't displayed and the begin of the text is repeated.
    I think that this issue is created at the creation of the PPR.
    If someone have a idea he is welcom.
    thanks and regards

    Hi,
    Please follow the note:425601,
    Go to Tcode: OBA5 change the error messge into warning message. carry out the settlement and roll abck the warning message into the error message after sucessfull settlement.
    Reward points if found useful.
    Thanks!

Maybe you are looking for