Way to populate data for current quater months from last month of previous quater

Hi  I have a requirement to load forecast data into the SSAS cube.
My current data:
Snapshot_M       Date         F_Quantities
1/1/2014        1/1/2014    100
2/1/2014        2/1/2014    90
3/1/2014        3/1/2014    80
4/1/2014        4/1/2014    23
4/1/2014        5/1/2014    0
4/1/2014        6/1/2014    0
I want this two be shown as
Snapshot_M       Date        F_Quantities
1/1/2014        2/1/2014    100
1/1/2014        3/1/2014    100
1/1/2014        4/1/2014    100
4/1/2014        5/1/2014     23
4/1/2014        6/1/2014     23
4/1/2014        7/1/2014     23
Snapshot_M filed is the month when data was loaded.
So to summarize, the data that is loaded in last month of fiscal Q1  (January) should serve as data for fiscal Q2 (Feb, Mar, APR), the data loaded on last month of Fiscal Q2 will serve as forecast data for Q3 an so on. ...
Thanks  

CREATE TABLE SAMPLEDATA(Snapshot_M DATETIME, Date DATETIME, F_Quantities INT)
--fixed
INSERT INTO SAMPLEDATA VALUES ('09/1/2013','09/01/2013',14)
INSERT INTO SAMPLEDATA VALUES ('10/1/2013','10/01/2013',13)
INSERT INTO SAMPLEDATA VALUES ('11/1/2013','11/01/2013',12)
INSERT INTO SAMPLEDATA VALUES ('12/1/2013','12/01/2013',11)
INSERT INTO SAMPLEDATA VALUES ('01/1/2014','01/01/2014',10)
INSERT INTO SAMPLEDATA VALUES ('02/1/2014','02/01/2014',90)
INSERT INTO SAMPLEDATA VALUES ('03/1/2014','03/01/2014',20)
INSERT INTO SAMPLEDATA VALUES ('04/1/2014','04/01/2014',23)
INSERT INTO SAMPLEDATA VALUES ('05/1/2014','05/01/2014',30)
INSERT INTO SAMPLEDATA VALUES ('06/1/2014','06/01/2014',70)
INSERT INTO SAMPLEDATA VALUES ('07/1/2014','07/01/2014',20)
--Desired result set:
Snapshot_M newdate F_Quantities
2013-10-01 00:00:00.000 2013-11-01 00:00:00.000 13
2013-10-01 00:00:00.000 2013-12-01 00:00:00.000 13
2013-10-01 00:00:00.000 2014-01-01 00:00:00.000 13
2014-01-01 00:00:00.000 2014-02-01 00:00:00.000 10
2014-01-01 00:00:00.000 2014-03-01 00:00:00.000 10
2014-01-01 00:00:00.000 2014-04-01 00:00:00.000 10
2014-04-01 00:00:00.000 2014-05-01 00:00:00.000 23
2014-04-01 00:00:00.000 2014-06-01 00:00:00.000 23
2014-04-01 00:00:00.000 2014-07-01 00:00:00.000 23
;with mycte as (select *, lead(Date,1)Over(Order by date) newdate
, Cast(Year(Snapshot_M) as char(4))+Cast(datepart(q, Snapshot_M) as char(1)) q
, row_number() over(Partition by Cast(Year(Snapshot_M) as char(4))+Cast(datepart(q, Snapshot_M) as char(1)) order by date) rn
,count(*) over(Partition by Cast(Year(Snapshot_M) as char(4))+Cast(datepart(q, Snapshot_M) as char(1)) ) cnt
from SAMPLEDATA
,mycte1 as (
Select rn, q,
(case when rn=1 then Snapshot_M end) Snapshot_M, newDate
, (case when rn=1 then F_Quantities end) F_Quantities from mycte
WHERE cnt=3)
Select
max(Snapshot_M) Over(partition by q) Snapshot_M
,newdate
,max(F_Quantities) Over(partition by q) F_Quantities
from mycte1
Order by newDate
drop table SAMPLEDATA

Similar Messages

  • Location of File Containing Data for "reopen all windows from last session"

    I'm a heavy-duty Safari user and usually keep 100+ tabs and windows open, carefully invoking the command "reopen all windows from last session" each time I restart. Unfortunately, I screwed up today and started and quit Safari without invoking "reopen all windows from last session," and all of my open tabs and windows are gone.
    I can recover the tabs manually using my history listings, but there must be an easier way: the information about the last session has to be stored somewhere. I did a Deja Vu backup on Friday and today I copied the files /~user/Library/Preferences/com.apple.Safari.plist and all the files from /~user/Library/Safari, including HistoryIndex.sk, History.plist, and LastSession.plist, from my backup to my hard drive, but the result was unchanged (that is, my 100+ tabs and windows were nowhere to be found).
    Given the time it takes for Safari to shut down, I assume it's storing a large history file somewhere, if only I knew where. Does anybody out there know or could otherwise help my recover from my stupidity?
    Thanks in advance.
    -- Kevin
    (proud Mac user for 23 years)

    I found a work-around. Since I frequently quit Safari and "reopen all windows from last session" upon restart, my history reflects all of the open tabs and windows contiguously. I thus reloaded the history file, invoked the command "History --> Show All History," found the most recent such contiguous history listing, shift-clicked and selected all relevant listings, and then double-clicked. All of my formerly open tabs and windows were reopened in tabs within a single window. I had to go back and rearrange things but it was far simpler than manually reopening all of those tabs and windows.
    -- Kevin

  • Can i add data for current month only

    can I add data for current month only?

        Knowing your plan options is important marlingut! So that we are able to provide correct information, what make and model phone are you trying to add data too? Is this device already activated on your account?
    Thank You,
    MichelleL_VZW
    VZW Support
    Follow us on Twitter @VZWSUPPORT

  • How to get data for current week and previous week using customer exit in Bex.

    Hi everyone,
    I have a scenario in which I need to display data for current week and previous week (based on "sy_datum" the program has to calculate current week and previous week) in Bex using  Customer exit. I have created one variable in Bex Query Designer and I have written code for the variable in CMOD. But it is not working fine, (I know that we can do the same by using offset value in Bex). Can some one guide me how to achieve my requirement using customer exit.
    Thanks in Advance,
    G S Ramanjaneyulu.

    Hi krishna,
    Thanks for your quick reply, can you have a look at my code,
    case i_vnam.
    WHEN 'ZPWK_CWK'.
    ranges : pre_week for sy-datum.
    data : start_date type DATS,
           end_date TYPE dats .
    ************FM TO GET FIRST DATE OF CURRENT WEEK ************************
    CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY'
      EXPORTING
        DATE_IN  = sy-datum
      IMPORTING
        DATE_OUT = start_date.   " WEEK FIRST DATE
    end_date = START_DATE + 6.   " WEEK LAST DATE
    END_DATE   = START_DATE - 1.   " PREVIOUS WEEK END DATE
    START_DATE = START_DATE - 7.   " PREVIOUS WEEK START  DATE
    **********PREVIOUS WEEK DATES IN PRE_WEEK******************
    pre_week-SIGN   = 'I'.
    pre_week-option = 'BT'.
    pre_week-LOW    = START_DATE.
    pre_week-HIGH   = END_DATE.
    APPEND  pre_week.
    CLEAR : START_DATE,END_DATE.
    endcase.
    Regards,
    G S Ramanjaneyulu.

  • Release Date for Albums Year, MONTH DAY

    Why can't I enter the release date for albums (Year month and day)?   Itunes has a field for year but that's it.    I would have loved to be at the meeting where it was discussed.
    "Year, month and day? why the heck would any want that?"
    "Well a lot of us want to see our albums in chronological order and you can't do that with just the year, many albums come out every year"
    "Blah Blah Blah, music is just to dance to, no one cares about dates, besides it would four extra digit fields in each entry"
    But seriously, I would think that Itunes would aspire to be THE program for music lovers.
    Instead of being able to just enter the release dates I have had to come up with my own work around.  I put a the release date in the format yyyymmdd in fromt of each title and then sort by titles.
    Now all of my Beatle albums finally show up in chronological order by release date.   But why should I have to massage the data like this.   I can't imagine what goes on at Itunes planning  sessions.  I'm very unhappy about the loss of cover flow but that's another story.

    I'm glad to hear that I am not the only one who sees this as a problem.  And another Beatles fan too.
    This is so fundamental.  Every album has a release date and it's part of the data that is always associated with  that album.   Why did Apple look at the data available for an album and consciously decide to truncate it?
    What kind of music lover isn't aware of when albums are released?  I just don't get it.
    I like having the date yyyymmdd in front of each album.   It isn't pretty but it means the albums are chronological.   If you want, you could just put this in the sort field and leave the regular album title in the regular field.   Then the names would be right and they would sort correctly.   But again.  Why should we have to do all that? 
    Apple is busy constantly changing where the controls are on I tunes  rather than fixing something simple and important like this.
    Today I wanted to load some songs onto my ipod touch and it took me 10 minutes to figure out how to sync because the last itunes update got rid of the side bar.  
    How are you supposed to get comfortable using a product when they keep moving the controls around?   Just quit apple.   leave the controls where they are.  Add new controls if needed but stop moving them.  I know I'm ranting now but I am honestly angry and frustrated,

  • How to populate data for 2LIS_40_REVAL, 2LIS_43_POSCAS and 2LIS_44_POSREC

    Hi
    How to populate data for 2LIS_40_REVAL, 2LIS_43_POSCAS and 2LIS_44_POSREC datasources at RSA3?
    I'm very new to retail BI.
    I think there is no setup tables for Retail infosources.
    Any IDoc or BAPI activation is required or other procedure?
    We are in BI-700 SAPKW70015 support pack R/3 side
    and SAP_BW 700 Support pack SAPKW70016 &
    BI_CONT 703 Support pack SAPKIBIIP9 BI side
    Can anyone guide me how to load data?
    Points assured
    Thanks in advance
    Ramana P

    Dear Ramana,
    There is no setup table for POSCAS and POSREC.This has to be popuated with a BADI Implementation. 
    As of PlugIns 2002_1_470 and 2002_2_470, POS data is update into BW the 2LIS_44_POSREC and 2LIS_43_POSCAS extractors using a BADI. To be able to update data into BW, the relevant implementation for the BADI must be activated in each case. You can activate the implementation in transaction SE19. The implementations are as follows:
    POS_EX_REC_PI2003_1 for extractor 2LIS_44_POSREC
    POS_EX_CAS_PI2003_1 for extractor 2LIS_44_POSCAS
    Once the activation of BADI , create the back ground jobs for the 44 application and the data is pushed into Delta queue and it can be loaded into BI .
    Hope this helps you.
    Thanks,
    Krishna Charan

  • Year To Date for Current Fiscal Year

    Hi All,
    I have installed BC variable Year To Date for Current Fiscal Year 0I_CFYTD..
    foloowing error occurs
    Variable 0I_CFYTD could not be replaced..
    Do i need to write any code or Please help.....

    Hi,
    Please check if fiscal year variant is used in the filter. Else the BC variable throws an error. Drag fiscal year variant to the filter area and set a value or variable input for the same.
    Regards,
    Satya

  • Date for every 3 months

    Hi experts,
    I have table with date and price . This table contains date for every day and corresponding price for that day. But I need to write a sql ,which outputs data for every three months .
    Eg: If my data in a table starts from jan-15-2009 to jan-15-2010 , then I should output the data like below .
    Jan-15-2009 20
    APR-15-2009 40
    JUL-15-2009 15
    OCT-15-2009 5
    JAN-15-2010 45
    Request all to help me . :(
    many many thanks in advance.
    Regards,
    Dirasa

    An alternative that doesn't require dates to be generated (again, apart from the setup data - nb. I have incorporated some of the logic into the data setup subquery, in order to make the final sql statement easier to read. You would replace "trunc(p_period_begin - 1 + level)" in the period_start_date column with whatever your date column is called):
    with param as (select trunc(sysdate) p_period_begin, 14 days_in_period from dual),
        my_tab as (select p_period_begin,
                          days_in_period,
                          p_period_begin - 1 + level dt_col,
                          trunc(p_period_begin) + days_in_period*floor((trunc(p_period_begin - 1 + level) - p_period_begin)/days_in_period) period_start_date,
                          level amount
                   from   param
                   connect by level <= add_months(p_period_begin, 12) - p_period_begin + 1)
    -- end of data setup
    select period_start_date,
           sum(amount)
    from   my_tab
    group by period_start_date
    order by period_start_date;
    PERIOD_START_DATE SUM(AMOUNT)
    17/11/2009                105
    01/12/2009                301
    15/12/2009                497
    29/12/2009                693
    12/01/2010                889
    26/01/2010               1085
    09/02/2010               1281
    23/02/2010               1477
    09/03/2010               1673
    23/03/2010               1869
    06/04/2010               2065
    20/04/2010               2261
    04/05/2010               2457
    18/05/2010               2653
    01/06/2010               2849
    15/06/2010               3045
    29/06/2010               3241
    13/07/2010               3437
    27/07/2010               3633
    10/08/2010               3829
    24/08/2010               4025
    07/09/2010               4221
    21/09/2010               4417
    05/10/2010               4613
    19/10/2010               4809
    02/11/2010               5005
    16/11/2010                731

  • Delete DSO data for current month on a daily basis.

    Hi Gurus,
    We have a requirement where we have to delete the data in the BW DSO's for the Current Month every day before loading data into it. The reason for this is that in R3 they delete data for the current month in addition to adding new records and changing existing records. Since we do a Full load in BW, the deleted records in R3 will still exist in the BW DSO, hence the need for deletion.
    We can't delete ALL the data in the DSO as we use the BW DSO for Archiving purpose and the R3 table at any point of time will have just 3 months of data, while BW will have historical data.
    I know there is a process to delete DSO contents in the Process Chain, but can it be set up to just delete the current months data??
    Thanks
    Arvind

    Hi Arvind,
    The program RSDRD_DELETE_FACTS or transaction DELETE_FACTS will help you in deleting the records. Execute the program and select the option 'Generate Selection Program'. It will create a Z program , you can then dynamically select the current month in the Variant and assign the Z program and the variant in ABAP step of the process chain.
    Hope this helps with your requirement.
    Regards,
    BINETWEAVER2004s

  • Bapi BAPI_REQUISITION_CREATE : how to populate data for sevices tab

    Hi all,
    I am creating a purchase requisition through bapi .I am using  bapi BAPI_REQUISITION_CREATE
    For creating purchase requisition. The bapi is  creating PR.
    I need to add item level services details also through bapi.i am Using structure BAPIESLLC to populate data. But the data is not getting populated in the services tab.
    For header data i am populating the following data.
    itab_bapiebanc-preq_item      =    '10'.
      itab_bapiebanc-doc_type       =    'NB'.
      itab_bapiebanc-short_text     =    'Blinding'.
      itab_bapiebanc-quantity        =    '1'.
      itab_bapiebanc-unit              =    'AU'.
      itab_bapiebanc-deliv_date      =    '20081027'.
      itab_bapiebanc-plant             =    '1000'.
      itab_bapiebanc-pur_group      =    '001'.
      itab_bapiebanc-preq_name    =    'tracking no'.
      itab_bapiebanc-trackingno     =    '2/C/1B'.
      itab_bapiebanc-mat_grp        =    '007'.
      itab_bapiebanc-acctasscat    =    'P'.
    itab_bapiebanc-ITEM_CAT      =    '9'.
    itab_bapiebanc-GR_IND          =    'X'.
    itab_bapiebanc-IR_IND            =    'X'.
    itab_bapiebanc-FIXED_VEND    =    ' '.
    APPEND itab_bapiebanc.
    itab_bapiebkn-wbs_elem        =    'E-2004'.
    itab_bapiebkn-g_l_acct  =  '0000417000'.
    APPEND itab_bapiebkn.
    itab_bapiebantx-PREQ_ITEM = '10'.
    APPEND itab_bapiebantx.
    when i am adding the above data the p,r is creating sucessfully in the system.
    I need to add data in the item level services tab also.
    I am populating for services tab .
    *----- this part is not working
    itab_bapiservices-SERVICE  = '100217'.
    itab_bapiservices-PCKG_NO  = '0000000001'.
    itab_bapiservices-LINE_NO  = '0000000001'.
    itab_bapiservices-EXT_LINE = '0000000010'.
    itab_bapiservices-short_text = 'BREAKFAST CNTR TOP; AS PER SPECS'.
    itab_bapiservices-QUANTITY  = '680'.
    itab_bapiservices-BASE_UOM  = 'M2'.
    itab_bapiservices-GR_PRICE  = '23.00'.
    itab_bapiservices-MATL_GROUP = '007'.
    itab_bapiservices-PRICE_UNIT = '1'.
    append itab_bapiservices.
    I am populating data for service tab like given above.But the value is not get updaing in purchase requisation.
    Please let me know how to populate the data for service tab.
    with regards,
    ambrose
    itab_bapiebantx-text_line      =    'Test for Purchase requisiton'.
    APPEND itab_bapiebantx.

    Hello
    Try this:
        CALL FUNCTION 'NUMBER_GET_NEXT'
             EXPORTING
               nr_range_nr                   = '01'
               object                        = 'SERVICE'
             IMPORTING
               NUMBER                        = pacno
             EXCEPTIONS
               INTERVAL_NOT_FOUND            = 1
               OTHERS                        = 8.
    itab_bapiservices-PCKG_NO = pacno + 1.
    Also Note 499626 - FAQ: BAPIs in the service

  • How to populate data for a field in data source

    Hi
      I have a field(VGBEL) in the data source 2LIS_11_VAITM, but i do not have data in it. I will have to populate data into it for that, I guess i need to write some  ABAP code .My question is where should i write the code.
    P.S If I have to write in the functional module or user exit how do i know the relavent functional module or user exit for the particular data source
    Thanks
    Sheetal

    HI sheetal,
    there will not be different user exit for each datsource. check this thread for the steps, which are general for any datsource.
    How to enhance datasources
    How to Data source enhancement i.e Transactional data
    you need to write your code in function module EXIT_SAPLRSAP_001 .
    hope it helps
    Regards
    Kiran
    *do assign points for helpfull answers.
    Message was edited by:
            ravi kiran naalla

  • Best way to export data for a migration

    Hi Oracle Community,
    What's the best way to export data from an Oracle 8i database for it to be suitable for import into an Oracle 10g database?
    What's the best way to export data if it is to go into different rdbms database?
    Thanks, David

    Thanks everyone for all your help. You guys are great.
    There seems to be many good ways to export your data from Oracle into a flat file format, suitable for import into other RDBS': Oracle, mysql, postgresql, etc.
    A few tools where mentioned but using SQL*Plus, which comes with Oracle (And SQL*LDR on the backend, which also comes with Oracle) seem the most straight forward.
    I found this script on asktom.oracle.com to work great, slightly modified here,
    (to Include linesize max, and pipes rather than commas):
    set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on
    set linesize 32767
    spool payment.txt
    select
    PAYMENT_ID||'|'||
    USER_ID||'|'||
    <more fields her>
    from
    payment
    spool off
    exit ;
    It works great. Rather than making one of these for each table I wrote an perl script called ora_export. http://crowfly.net/oracle/ora_export. It runs in Unix and only requires SQL*PLUS. It creates these four files:
    <tablename>.def # list of table columns and types (SQL*Plus DESC)
    <tablename>_dump.sql  # a script to export the data
    <tablename>.psv # THE DATA (eq. - name|address|etc)
    <tablename>_load.ctl  # SQL*LDR control for ORCL if you need it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Fetching data for past 13 months

    Hello Team
                       I have a data model . Now i want some suggestions . My requirement is that when i try to pull data from my HANA DB i should give current data and automatically the data of past 13 months should come . What technique i should apply to achieve the same .
    Regards

    Hi,
    Have a look on the below documents:
    How To...Calculate YTD-MTD-anyTD using Date Dimensions
    Applying YTD in SAP HANA with SAP BO Analysis Office ( Using Projections )
    Regards,
    Krishna Tangudu

  • Best way to retrieve data for jsp

    Hi,
    I'm fairly new to java and am preparing to create some jsp's for our intranet. The pages need to include data from a db2 database. I know pretty much what I need to do, but I'm trying to decide the best(most efficient) way to retrieve the data to display. I've looked at a number of examples and the more I look, the more confused I get (it would be so easy on the AS400 which is my background so you can see how new this is to me). I see my options as: using an 'include' statement to include another java file that retrieves the data; or use a java bean; or just instantiate an instance of the class and 'call' the methods for that class directly; or lastly, place all the code directly in the jsp to connect to the database and query the table.
    What's the real difference between these options and what's usually the most efficient and preferred way?
    Thanks for any advice and clarification.

    As a general rule, it's a good idea to separate the
    presentation (JSP and HTML) from the business rules
    (database access). I know you didn't do that on the
    AS/400, you had display files and business logic in
    the same program (at least, we certainly do in ours),
    but it's a good policy to follow in the web world.
    That means, don't put your database access code in
    the JSP. Other than that, it depends on the data.
    If you have simple data (e.g. customer's name and
    d address) then a Java bean would suffice. If you
    have complex data (e.g. customer's payment history)
    then a bean still might suffice. You would use an
    "include" if you had some data (static or dynamic)
    that you wanted to appear in several different pages
    in the same form.Thanks, I figured putting the code in the JSP was not the best way, but I wasn't sure about the other options.

  • ASCP Planned orders recommendation date for current week

    Dear Experts,
    I am facing the below issue in Decentralized ASCP workbench.
    In the forecast demand date is 18-04-11, 25-04-11, 02-05-11 and so aon (Weekly buckets).
    After launching plan today (18-04-11), Recommendation in workbench are showing due dates as 19-04-11, 25-04-11, 02-05-11 and so on.
    The question here is, Why the current week demand is shifting one day (19-04-11). Business requirement is today (18-04-11).
    Appreciating your valuable soluation.
    Note:
    (We checked planning time fence. Items having the value 0, 1 are also giving the same result)
    Regards,
    Ramesh

    Sandeep Gandhi,
    Yes, ASCP can not schedule anything in the past but it will suggest planned orders for today (Plan run date) for the past demands.
    Example: Forecast Demand due date : 16-04-11.
    when we run the plan today, ASCP have to suggest planned order for today's due date (18-04-11)
    But we don't know why it is shifting to 19-04-11 (tomorrow).
    Your valuable suggests will be very helpful
    Regards,
    Ramesh

Maybe you are looking for