Annual Sales Comparison Analysis by Year - Query

Hi,
I need some help please!
I need a query where I can compare sales to the previous year, preferably with manual date range entries.
CardCode u2013 CardName u2013 SalesX u2013 SalesY
Where the date range is the same but SalesY is for the corresponding time 1 year back.
I can get the individual totals for each year but I cannot get to combine the two years in one report.
Thanks.

Hi Desmond,
Sorry, just get spare time to read and reply your post.
I'm gonna give you explanation regarding your statement here "I notice that if I manualy type in a date in the date range and there is no posting on that date it will generate a blank report".
Unlike SQL stored procedure or function where you can pass any value to the passing parameter (as long as you pass appropriate data type), you have to pass value from certain table in B1 if you do the query in B1 query generator.
Thus, this following code:
DECLARE @DateFrom AS DATETIME
DECLARE @DateTo AS DATETIME
SELECT @DateFrom=DocDate FROM OINV T0 WHERE T0.DocDate='[%0]'
SELECT @DateTo=DocDate FROM OINV T1 WHERE T1.DocDate='[%1]'
You can't do something like this for instance (in B1 query generator case):
DECLARE @DateFrom AS DATETIME
DECLARE @DateTo AS DATETIME
SET @DateFrom='[%0]'
SET @DateTo='[%1]'
So, you need to select from certain table (I use OINV in this case) as a bait to contain the variable with a value.
Therefore, the reason you didn't get any result if you typed the data manually, it wasn't due to manual input / you choose the date from drop down. It was merely cause by the date which you entered manually doesn't have any record in OINV table. Make sense isn't it, it is as if you try to do the following query
SELECT @DateFrom=DocDate FROM OINV T0 WHERE T0.DocDate='1/1/2012'
where actually you don't have any record in OINV table with '1/1/2012' date.
So, you could change above code with this
DECLARE @DateFrom AS DATETIME
DECLARE @DateTo AS DATETIME
SELECT @DateFrom=RateDate FROM ORTT T0 WHERE T0.RateDate='[%0]'
SELECT @DateTo=RateDate FROM ORTT T1 WHERE T1.RateDate='[%1]'
or this
DECLARE @DateFrom AS DATETIME
DECLARE @DateTo AS DATETIME
SELECT @DateFrom=RefDate FROM OJDT T0 WHERE T0.RefDate='[%0]'
SELECT @DateTo=RefDate FROM OJDT T1 WHERE T1.RefDate='[%1]'
Because, logically, you should have much more date data in those two table (ORTT for daily exchange rate and OJDT for journal entry). It doesn't mean you want to retrieve data pertaining with exchange rate or journal entry, as I said in above, it serve only as a bait to fill your parameter @DateFrom and @DateTo used in your query logic with date value. The table itself doesn't matter.
Hope now you could understand the basic concept here.
Best Regards,
Hendry Wijaya

Similar Messages

  • Query for Sales Order Analysis

    Dear Experts
    I have written a Query for Sales Order Analysis and would like to have help on this.
    The query is used for generating daily report for Sales Order on number of documents (Sales Order), total amount of sales orders and total GP of Sales Order. The query is written as below:
    SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
    FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum] ORDER BY T0.[DocNum]
    where U_Total_GP is a UDF for storing the GP of each order.
    After executing the query, a selection criteria of date appears and after a date is selected, the report shown information required. However, the query does not calculate column total for total amount and total GP. Although I know the total for each column can be displayed by pressing "Ctrl" + Click on the column title, it would have to be done from time to time.
    Therefore, I would like to modify my query in order to calculate the column totals when executed. Are there any suggestions for this?
    Thank you
    Regards
    Elton

    Hi Elton,
    Try this:
    SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
    FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
    Union ALL
    SELECT '', SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
    FROM ORDR T0 WHERE T0.[DocDate] =[%0]
    ORDER BY T0.[DocNum]
    Thanks,
    Gordon

  • Query on Sales Order Analysis

    Dear Experts
    I have written a Query for Sales Order Analysis and would like to have help on this.
    The query is used for generating daily report for Sales Order on number of documents (Sales Order), total amount of sales orders and total GP of Sales Order. The query is written as below:
    SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
    FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
    Union ALL
    SELECT '', SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
    FROM ORDR T0 WHERE T0.[DocDate] =[%0]
    After executing the query, a selection criteria of date appears and after a date is selected, the report shown information required. Everything is fine with this query except I would also like to incdude the total number of Sales Order (per day) right below the column "DocNum".
    Is it possible to achieve this?
    Thank You
    Regards
    Elton

    Try this:
    SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
    FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
    Union ALL
    SELECT count(DocDate), SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
    FROM ORDR T0 WHERE T0.[DocDate] =[%0]

  • ANNUAL SALES REPORT (MONTH WISE)

    Hi,
    I have following query, which shows annual sales (month wise). But when i run this query it shows all the parts (my mass production and Spare parts as well). I want it should show only MASS Production items only.
    The differencation i have specified at Item level property. If item property no. 5 (name SPARES) is check then it is SPARE item otherwise it is MASS Production.
    Thanks,
    Vincent
    ======================================================
    SELECT T0.ITEMCODE, T0.ItemName, T0.U_MODEL,
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 1 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'JAN QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 2 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'FEB QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 3 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'MAR QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 4 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'APR QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 5 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'MAY QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 6 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'JUN QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 7 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'JUL QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 8 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'AUG QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 9 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'SEP QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 10 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'OCT QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 11 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'NOV QTY',
    (SELECT SUM(T1.QUANTITY) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 12 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'DEC QTY'
    FROM dbo.OITM T0
    LEFT JOIN dbo.INV1 T1 ON T1.ItemCode = T0.ItemCode
    WHERE T0.SellItem = 'Y'
    GROUP BY T0.ItemCode, T0.ItemName, T0.U_MODEL, YEAR(T1.DOCDATE) HAVING YEAR(T1.DOCDATE) = YEAR(GETDATE())

    Hi Rahul,
    Yes this report is very much available, but my idea was to integrate an udf (Model No., which i didn't specify in this query).
    But yes this report is very usefull for me.
    Thanks
    Vincent

  • AGO function in OBIEE to display weekly sales data of this year vs last yea

    All,
    I would to create an analysis that display this year sales numbers vs last year by weekly
    I was able to do this at month level by specifying the offset value to 12 to the AGO function in repository.
    I am not able to do at week level.
    Can someone please help?
    Thanks

    Check the W_DAY_D or W_WEEK_D for number of weeks per year, validate the year/4 then its leap year then 53
    Use this in ago function at <<Number of Periods>>.
    I think you have to go for 53 based on these tables some times 54.

  • Year Over Year Comparison for Multiple Years

    I have a business request where the client is asking for a year over year percentage comparison for multiple years
    So for example
              Applications
    2015     5
    2014     10
    2013     22
    So in year 2015 we can see that applications is currently down (5-50/10 - [New-Old/Old] by -50% compared to year prior
    In year 2014 we are down -55%
    Ultimately I wanted to display the following
              Applications
    2015     -50%
    2014     -55%
    2013    
    I have an idea of how to do this for a single year, where a presentation variable is fed in then I can just do this year minus previous year.
    I was wondering, how can I do this calculation or presentation in OBIEE? Can this be done within answers? Or does something need to be done in the RPD?

    As long as your model is correctly done with a time hierarchy you can just use the time series function AGO to get the value of previous year.
    So in the formula you can calculating your delta in % comparing the current year amount and the previous one.
    You can do it in the analysis directly, but if you will often need to access "previous year measures" would be a good idea to add it in the RPD so you don't need to write the formula every single time.

  • How to get / configure data in Tcode "MCTG" for "SIS: Sales Office Analysis Selection "?

    Hello SAP Guru's,
    How to get / configure data in Tcode "MCTG" for "SIS: Sales Office Analysis Selection "? We have implemented SAP ECC 6.0 EHP4 version in the organization. If anybody have any idea, need help .
    Thanks in Advance.
    Prashant Kunjir

    Have a look at the following note:-
    Note 1573200 - How to restructure the statistic data of the sales information system (SIS)
    But before trying to carry out the process as detailed in the above note, first check with other SIS reports like MCTA etc., and no reports are showing correctly, then you can proceed.  Otherwise, you need to raise an OSS message with SAP.
    G. Lakshmipathi

  • KE30-COPA Group Sales Margin Analysis

    HI All,
    We have an issue with COPA Group Sales Margin analysis report, (KE30) .We are not able to see the journal entries for revenue from GL,the journals created thru FB50 and these entries are showing up in KE24-Dispaly actual line item report,That means PA documents are being created as well.Do we need to do any additional assignment while crearting journal entry.Currently we have assigned profit center in PA segment field.Thanks
    Regards
    Shaun

    Cant we repost journals with assignment of Sales org, Dist.Division to make the data available in KE30 report.That would be good option .I am not sure about KEDU,how to run it or rebuild it.Thanks for your reply.
    Regards\
    Shaun

  • How to see sales done in previous years

    Hi,
    I want to see the sales done in previous years like in 2003 or 2004 and are archieved. What is the procedure to see those sales.
    Regards,
    Bhaskar.K

    Hi,
    You can check these in tables through SE16.
    Sales done means billing done, so use VBRK table and give the date range.
    <b>Reward if ti helped!</b>
    Chandru

  • All about  PnL[Profit and Loss] and SGA[Sales Growth analysis]

    hello SDN.
    I have just joined a consumer goods MNC as an executive trainee working on SAP BI.
    My current profile is on SGA loading and  PnL loading.
    Can anyone tell me more about SGA and PnL.
    I do not want the SAP technical points.
    I need the core business explanation for these topics.
    Why are they needed and what role they play at the management level, etc...
    Waiting for the reply eagerly
    Thanks

    Hi,
    I think u r asking more on functional analysis, Management uses Sales Growth Analysis (also called Top Line analysis) to know the growth rate in their Revenues, it shows their Market share and customer retention and new customers added, whether their promotional campaigns worked or not? like this it helps the management.
    Coming to Profit and loss analysis or also called as Bottom line analysis, it shows their efficiency in optimum utilization of resources, increase or decrease in operating expenses etc.
    based on the above two analysis, the scenarios may be like this:
    Revenues increased, but profit come down, what r the reasons?
    Revenues decreased, but profits increased, reasons?
    etc.
    this may be useful
    Thanks
    Ganesh

  • MC+2, Sales Org Analysis

    Dear all
    In Tcode MC+20 (Sales Org Analysis Report) there are Incoming orders qty field. we want to know, what is "Incoming orders qty", and where are from, from which the amount obtained
    thanks
    imron

    what is "Incoming orders qty",
    Whatever sale order is created, the quantity would be cumulated and populate in this field.
    thanks
    G. Lakshmipathi

  • Sales Employee analysis

    Hello,
    We do not have SAP HR module implemented, so I have created a new Account Group for Sales Employee and the Sales Employee partner function is linked to all my Sales Document type. I want to know, how will I be able to generate the Sales Employee Analysis (T.Code MCTI) in this case.
    Regards
    Ravi

    Hi Ravi
    First of all  Welcome to SDN forum
    First of all maintain data by doing the assignments  in OVRO and OVRP
    But make sure that you have maintained Customer statistics grp in CMR->sales area data ->sales tab
    In the same way make sure that you have maintained Material statistics grp in MMR->sales orgn1 tab->material statistics grp
    Now run the report MCTI then you will get the data
    Regards
    Srinath

  • Sales Organization Analysis

    Hi all,
    I run MCTE Sales Organization Analysis report, it's alway show No data exits for chosen selection, Althought, i chose suitable Sales Org and Period. I'm sure that it has data.
    Pls help me.
    Thanks,

    Dear Quang
    It seems the said field is missing at your end and hence the issue.
    Go to OBD2, select the account group, double click on Sales data.  Again double click on "Sales"  and place your mouse on "Req.Entry"  and save.
    Now go to customer master and see whether that field is flowing.
    thanks
    G. Lakshmipathi

  • Sales organization with 0SALES_CUST  in query

    Hello Guys
    I'm using infobject 0SALES_CUST in a query but i'd like to show only N° of customer and not all data about sales organization.
    Now in query it is display : LI/DS/SA01/30000010  where LI DS SA01 are sales org. and 300000010 is the customer.
    I'd like to show only the customer
    do you have any idea?
    Thanks in advance
    Boris

    Thanks Guys for the answers,
    i tried to manage compound in infoObject but i have too many errors becouse the object is already used in Infocubes and query therefore is not possible to change it.
    Probably i can change the display directly in the query but i need to fix another issue before.
    I can not update text for this infoobject 0sales_cust, i activated datasource 0CUST_SALES_TEXT created transformation and infopack but when i update text in PSA  i have red light with this message on all record:
    0CUST_SALES : Data record 670 (' ') : Duplicate data record     RSDMD     191
    For this infoObject i have already update attribute and hierarchy without any problem and now i need to update also the text
    Do u have any idea??
    Kind regards
    Boris

  • Frequency Analysis - batch automation Query

    Hi,
    I was wondering if its possible within adobe audition to automate a process of performing frequency analysis on a batch of audio files and saving the frequency analysis windows in individual bmp files?
    There is a file batch utility which I am aware of for processing groups of files. However with the frequency analysis window - the only way of saving this window is by Alt-PrintScreen and manually saving file to another bitmap package.
    Is anyone aware of a way/system/tools of achieving this ?
    Thanks for any suggestions
    - Darragh

    ok, thanks for the tip.
    Date: Wed, 22 Jul 2009 17:54:18 -0600
    From: [email protected]
    To: [email protected]
    Subject: Frequency Analysis - batch automation Query
    There's no way of doing this within Audition, but I think that there are external batch process programs that might let you do this using Audition - if you see what I mean. I don't personally do things like that, but maybe somebody who does could recommend one? Alternatively, and probably rather a better bet, re-ask the question on the AudioMasters forum. You are more likely to get a meaningful response, quite frankly.
    >

Maybe you are looking for

  • Error while Uploading PO's into Oracle

    I tried 2 different ways of uploading PO into Oracle SOA Suuite 11.1.1.3.0 JDev : 11.1.1.3.0 Oracle EBS 11.5.10.2 1. Calling the Stored procedure which has fnd_request.submit_request 2. Using Oracle Applications Adapter and calling the standard concu

  • Dynamic table with drop down lists

    I have a Dynamic table with a header row, Section and footer row. Section has the following cells(columns): Cell1 (drop down with locations), button (to remove row), CCode (Color Code RAL), CName (color name). I'm starting with 1 row. now what I want

  • IPhone 4s (6.1) gets message or whatsapp message, vibrates but doesn't display new message notification on screen

    As per title really. Whenever i get a text or whatsapp message my phone vibrates (sometimes twice as if i have two messages) but nothing is displayed on screen. This is ever since updating to 6.1

  • HP 17" Pavilion dv7-1261wm

    My daughter wants this HP 17" Pavilion dv7-1261wm computer.  It has a ATI Radeon HD 3650 graphics card. I was wondering if any of you have this computer and how you like it. How good is it for gaming. I know its not the best graphics card, but I was

  • I can't turn off airplane mode

    i have an HP laptop with windows 7 and the airplane mode won't turn off.     the key pushes in easily but i just cannot get a blue light instead of the red one.......and of course, i can't get connected to the internet.