Previous month year

I have 2 tables-> facts and facts1 and i have to create a "sale revenue - last completed month" metric based on the columns of the tables.
the formula on the metric right now is CASE WHEN ."Last Completed Month Indicator" = 'Y' THEN ("Sale Order Cost" +"Sale Order Cost Promotional Adjustment") / USD SPot Rate" END
i have another table "month year" which has a columns "previous month year key no" which is in the format 190001 ( january 1900) ,"previous month year description" , "previous month year name".
I need to use this previous month year column and put it in the metric above and calculate the revenue for last completed month. Can i do it???
Thanks!

Hi,
what is the granularity of fact table and how is it related to month year table?
Also are the fact tables partitioned? If they are partitioned AGO and TODATE functions cannot be used.
Is any of the fact tables aggregated???
-bifacts
http://www.obinotes.com
J

Similar Messages

  • How to Include previous Month/Year in Transformation

    Hi,
    From Source System (DB Table;DB Connect)
    Location_ID,EMP_ID,AMOUNT
    There is no date field avaliable in the source system.
    The Data load to BW will me Monthly frequency...I,e:Data will be loaded once in a Months on 1st of every month.
    My requirment is to Include a date field in BW transformations which input previous month/year data for every record
    How can i do that and wether do i need to write a start or field routine in transformations
    Code please
    Thanks

    Hi Pal,
    You could use the following code to achieve this:
    DATA: v_calmonth(6) TYPE c,
          v_month(2) TYPE c,
          v_year(4) TYPE c.
    v_month = sy-datum+4(2).
    v_year = sy-datum+0(4).
    IF v_month = 1.
      v_year = v_year - 1.
    ENDIF.
    IF v_month = 1.
      v_month = 12.
    ELSE.
      v_month = v_month - 1.
    ENDIF.
    CONCATENATE v_year v_month INTO result.
    Hope this helps.
    Thanks and Regards
    Subray Hegde

  • Display Month and 12 previous Months

    I am trying to create a report (CRXI) which will display month data for the current month and the 12 previous months.   I am going to use subreports (similar to a calendar report) but am having trouble displaying the 12 previous month, year  headers.  
    I get the current month, year from a prompt date and then need to decrease a month for 12 months.  
    Any help would be appreciated.

    Hi Martha,
    If you want to create a report for last 12 months and don't want to include present month then use the record selection for main report as
    (month({DateField}) < month(currentdate)
    and
    year({DateField})= year(currentdate))
    or
    (month({DateField})>=month(currentdate)
    and
    year({DateField})=year(currentdate)-1)
    and in the subreport use the record selection to get current month date as
    (month({DateField}) =month(currentdate)
    and
    year({DateField})= year(currentdate))
    Regards,
    Raghavendra

  • Input: Month Year and Out Put Display

    Dear SDN,
    Is it possible to view a Query, if we provide only Month & Year..
    Then the following result has to display..
    Entered month year --- Previous month year --- YTD entered month -- YTD Previous month year
    Example : During execution of a query -- suppose if i enter Sep 2007
    Sep2007 -- Sep2006 -- YTD Sep2007 -- YTD Sep2006
    Please suggest me...
    Help will appreciated with points
    This is very urgent...
    Thanks in advance

    Hi,
    Create a VAR Ready for input on 0FISCPER (eg ZFPIN)
    COL 1: RKF with your KF restricted to 0FISCPER = ZFPIN
    COL 2: RKF " 0FISCPER = ZFPINLY
    COL 3: RKF " 0FISCPER = ZFPINYTD
    COL 4: RKF " 0FISCPER = ZFPINLYYTD
    ZFPINLY, ZFPINYTD, ZFPINLYYTD are variables NOT ready for input processed by customer exit (CMOD).
    The code should basically be:
    DATA: l_s_range     TYPE rsr_s_rangesid.
    DATA: loc_var_range LIKE rrrangeexit.
    DATA: fiscal_year LIKE t009b-bdatj.
    CASE i_vnam.
    WHEN 'ZFPINLY'.
    IF I_STEP = 2.
    LOOP AT i_t_var_range INTO loc_var_range
    WHERE vnam = 'ZFPIN'.
       fiscal_year = loc_var_range-low(4).
       fiscal_year = fiscal_year - 1.
       CONCATENATE fiscal_year loc_var_range-low+4(3) INTO l_s_range-low.
       EXIT.
    ENDLOOP.
    l_s_range-sign     = 'I'.
    l_s_range-opt      = 'EQ'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    WHEN 'ZFPINYTD'.
    IF I_STEP = 2.
    LOOP AT i_t_var_range INTO loc_var_range
    WHERE vnam = 'ZFPIN'.
       CONCATENATE loc_var_range-low(4) '001' INTO l_s_range-low.
       l_s_range-high = loc_var_range-low.
       EXIT.
    ENDLOOP.
    l_s_range-sign     = 'I'.
    l_s_range-opt      = 'BT'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    WHEN 'ZFPINLYTD'.
    IF I_STEP = 2.
    LOOP AT i_t_var_range INTO loc_var_range
    WHERE vnam = 'ZFPIN'.
       fiscal_year = loc_var_range-low(4).
       fiscal_year = fiscal_year - 1.
       CONCATENATE fiscal_year '001' INTO l_s_range-low.
       CONCATENATE fiscal_year loc_var_range-low+4(3) INTO l_s_range-high.
       EXIT.
    ENDLOOP.
    l_s_range-sign     = 'I'.
    l_s_range-opt      = 'BT'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    ENDCASE.
    hoping this will guide you....
    Olivier.

  • FM to get previous fiscal month/year and calendar month/year for a date.

    Hi All,
    I am having a requirement to extract some data based on either the previous fiscal month/year or the previous calendar month/year. There is no company code input to find the fiscal/calendar month/year.
    At selection screen, user can select either fiscal or calendar selection.
    Based on the selection, the data will be extracted.
    For the system date, we need to calculate previous fiscal month/year or previous calendar month/year and populate the calculated data back to the selection-screen.
    Can you one of you please suggest an FM to find previous fiscal month/year and previous calendar month/year.
    Thanks in Advance,
    Regards
    Gowthami

    Hi Gowthami,
    You can use following function module to calculate previous / next day or month or year.
       call function '/SAPHT/DRM_CALC_DATE'
          exporting
            date      = sy-datum
            days      =
            months    =
            sign      = '-'
            years     =
          importing
            calc_date = .
    Here, you can give '-' to sign, if you want previous day / month / year.
    Here, you can give '+' to sign, if you want next day / month / year.
    And depending upon your requirement, you can pass suitable value to days / month / year.
    e.g. To calcualte last month,
       call function '/SAPHT/DRM_CALC_DATE'
          exporting
            date      = sy-datum
            days      =
            months    = 1
            sign      = '-'
            years     =
          importing
            calc_date = wv_prev_month.
    so it will give '23-01-2008' . Then convert it in the required format as per your requirement using string function concatenate.
    Hope this help you.
    Regards,
    Anil

  • MDX calculation based on date logic for the Jan 1 of current year through the 15th of the previous month

    Hello, 
    We need some help with an SSAS MDX query based on date logic. One of the problems is that I don't have access to the Cube but have been given a query example with the logic needed for the calculation. Here's the scenario; 
    The ETL process will run on the first Tuesday after the 15<sup>th</sup> of a given month. The Analysis Cube data queried should include the current year up to the end of the previous month. For example, on May 19<sup>th</sup>
    (the first Tuesday on or after the 15th) the query should include data from January 1<sup>st</sup> through April 30<sup>th</sup>.
    The 15<sup>th</sup> of the month is not part of the query, it is a factor in when the query is run. The query will always be in terms of complete months.
    SELECT
                    NON EMPTY { [Measures].[Revenue Amount],
                    [Measures].[Utilization],
                    [Measures].[AVG Revenue Rate],
                    [Measures].[Actual Hours] }
    ON
                    COLUMNS,
                    NON EMPTY { ([dimConsultant].[User Id TT].[User Id TT].ALLMEMBERS * [dimConsultant].[Full Name].[Full Name].ALLMEMBERS * [dimConsultant].[Employee
    Type].[Employee Type].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,
                    MEMBER_UNIQUE_NAME
    ON
                    ROWS
    FROM
                    ( SELECT
    ( { [dimDate].[Week Date].[1/4/2015], [dimDate].[Week Date].[1/11/2015], [dimDate].[Week Date].[1/18/2015], [dimDate].[Week Date].[1/25/2015], [dimDate].[Week Date].[2/1/2015] } )
                    ON
                                    COLUMNS
                    FROM
                                    ( SELECT
    ( { [dimIsBillable].[Is Billable].&[True] } )
                                    ON
    COLUMNS
                                    FROM
    [SSASRBA]
    WHERE
                    ( [dimIsBillable].[Is Billable].&[True], [dimDate].[Week Date].CurrentMember ) CELL PROPERTIES VALUE,
                    BACK_COLOR,
                    FORE_COLOR,
                    FORMATTED_VALUE,
                    FORMAT_STRING,
                    FONT_NAME,
                    FONT_SIZE,
                    FONT_FLAGS

    Hi Hans,
    Thank you for your question.  
    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.  
    Thank you for your understanding and support. 
    Regards,
    Simon Hou
    TechNet Community Support

  • FM to calculate date month & year six months previous to the current date

    Hi All,
    Is there any function module or code to calculate date month & year six months previous to the current date.
    Thanks in advance.

    hi,
    try this
      data : date1 like vbak-erdat.
    data : q type numc3.
    selection-screen : begin of block blk2 with frame title text-001.
    parameters : n like q.
    selection-screen : end of block blk2.
    if n > 0.
    CALL FUNCTION 'CCM_GO_BACK_MONTHS'
             EXPORTING
               CURRDATE         = sy-datum
               BACKMONTHS       = n
           IMPORTING
              NEWDATE          = date1
    selection-screen: begin of block blk1 with frame title text-001.
    select-options :  s_date for vbak-erdat default 'NEWDATE'  to 'sy-datum' no-display.
    selection-screen : end of block blk1.
    write : date1.
    Reward with points if helpful.

  • Calculating previous month and year of the previous month

    Hi frenz,
    Can anybody know FM to calculate the previous month and year of the previous month.
    are there any standard FMs existed to achieve this?
    br,
    anil.

    hi,
    lv_period gives the month and year which is two months earlier now as we have specified lv_months as -2.
        DATA: LV_PERIOD LIKE S001-SPMON,
              LV_MONTHS(2) TYPE C VALUE '2-',
              LV_DATUM LIKE SY-DATUM,
              LV_NEWDT LIKE SY-DATUM,
            P_SPMON LIKE S001-SPMON VALUE '200601'.
        CONCATENATE P_SPMON '01' INTO LV_DATUM.
        LV_PERIOD = P_SPMON+0(6).
        CALL FUNCTION 'MONTH_PLUS_DETERMINE'
             EXPORTING
                  MONTHS  = LV_MONTHS
                  OLDDATE = LV_DATUM
            IMPORTING
                 NEWDATE = LV_NEWDT
             EXCEPTIONS
                  OTHERS  = 1.
         IF SY-SUBRC = 0.
           LV_PERIOD = LV_NEWDT+0(6).
         ENDIF.
    WRITE :/ LV_PERIOD.
    Regards,
    Sailaja.

  • Reporting on Previous Month/Current Year - Jan 09 fix

    I currently have about 10 reports that are being filtered to only show data on the repository variables for :
    PreviousMonth and Current Year.
    When Jan 1, 2009 comes around, these reports will be kicked off to show Decemeber of the Current Year, so December of 2009.
    What is the best/easiest way to fix this problem for the future?

    What Shiva meant was to let YEAR be a Presentation Variable that the user can select from, say a drop down list of "years."
    But consider this. Whenever the month of the "system date" is January, you want the year to be one less than the "current year." For all other months, you want the year of the "system date."
    PrevYear = CASE WHEN MONTH(Calendar."System Date")=1 THEN YEAR(TIMESTAMPADD(SQL_TSI_YEAR, -1,Calendar."System Date")) ELSE YEAR(Calendar."System Date") END
    And since you weren't sure about how to do the previous month...
    PrevMonth = MONTH(TIMESTAMPADD(SQL_TSI_MONTH,-1,Calendar."System Date"))

  • Reg : Curr Month,Previous Month,Curr Month Previous Year

    Hi all ,
                 I have a req where I have to display the sales for
    Current Month               Sales value
    Previous Month             Sales value
        Curr Month                Sales 
    Previous Year
    Curr Month and Previous Month I got it with Time Series AGO Function .
    But current month for the Previous Year , I am not able to proceed .
    Kindly help.
    Reg,
    Niv D

    Hi NIV,
    You can use the same time series function to calculate current month of last year values.
    Ago (measure column , year , 1)
    it describes the last year sales of current month
    OBIEE -Time Series in OBIEE
    Regards,
    VG

  • How to get the previous month and year accordingly

    Hi friends,
    I wanted to select month as number like 4 and year as 2011
    but I want to select the previous month as of sysdate
    like if the sysdate is 10-jun-2011
    it should give me 5 as month and
    in the year it should give as 2011
    if the sysdate is 01-jan-2012
    the month should be as 12 and year should be as 2011
    thanks

    Hi,
    776317 wrote:
    thanks a lot I just dont need the 0 being prefixed... can you pls tell how to avoid that as well pls
    TO_CHAR ( ADD_MONTHS (SYSDATE, -1)
            , 'FMmm yyyy'
           )For details about how the FM modifier works, wee the SQL Language manual:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements004.htm#sthref456

  • Query returns data from previous month. Need to have it return data for the entire year

    This is the part of the query that returns data by month:
    (YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)AND MONTH(`rereport`.`market_reports_5`.start_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH))
    How can I get it to return data for the year.
    TIY

    How about omitting the MONTH part:
    (YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Same date of previous month / Leap year

    In my requirment , I am passing a date, I want a function module which will return me the same date of last month. I have found a function HR_PSD_DATES_ADD_MONTHS , but it is not giving output if I pass date as 31st March 2000 , as previous month is February and its a leap yr.
        If you know  function module which could help me , pls help me.

    Hello,
    Try this way :
    REPORT ZTEST_NP .
    parameters: p_dt type d.
    data:
    lst_dt type d,
    l_dt type d,
    days type i,
    prv_dt type d.
    l_dt0(4) = p_dt0(4).
    l_dt4(2) = p_dt4(2) - 1.
    if l_dt+4(2) le '00'.
    l_dt+4(2) = '12'.
    endif.
    l_dt6(2) = p_dt6(2).
    CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
      EXPORTING
        DAY_IN                  = l_dt
    IMPORTING
       LAST_DAY_OF_MONTH       = lst_dt
    EXCEPTIONS
       DAY_IN_NO_DATE          = 1
       OTHERS                  = 2
    if lst_dt ge l_dt.
      prv_dt = l_dt.
    else.
      prv_dt = lst_dt.
    endif.
    write: prv_dt.
    regards,
    Naimesh

  • Parameter for Current Month and Previous Month

    I'm trying to create a parameter for current month and previous month based on the ex_date, but not sure what i'm doing wrong. 
    where ex_date = @SelectDate
    I created a second dataset below for the values in the parameters.
    SELECT Month(CURRENT_TIMESTAMP) AS 'Month', 'Current Month' as 'Current Month'
    union all
    SELECT Month(CURRENT_TIMESTAMP)-1 AS Month, 'Previous Month' as 'Previous Month'
    Results
    Month Current Month
    3 Current Month
    2 Previous Month
    Once I preview it I get "Conversion failed when converting date and/ or time from character string" I changed the data type to "date/Time" but that did not make a difference. The date is convert (varchar(10), ex_date, 101) so looks like
    11/12/2014. 
    I've also tried expressions like =month(now()) to pull current month with same error so i'm not sure what i'm doing wrong. Any ideas?

    i tired this real simple report
     in the first dataset - my main report query - select name from sysdatabases where month(crdate())=@month
    in the second dataset - select month(getdate()) as Month1
    in the parameters - choose int data type and available values - select the second data set
    in the first data set- add this parameter..( i am assumming you know this, since you have done)
    in the preview you should get the drop down with current month number - 3
    and if you run the report, it will display the database names that were created in march. remember we are no checking year, so will get all that were created in march across the years.
    Hope it Helps!!
    I'm looking to have the dropdown say "Previous Month" and "Current Month" as a option. I know how to get the information in SQL, but not sure how this translates or put into a parameter.
    Current Month
    list_date BETWEEN
    DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)
    AND
    DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0)
    Previous Month
    list_date between
    CONVERT(varchar,dateadd(d,-(day(dateadd(m,-1,getdate()-2))),dateadd(m,-1,getdate()-1)),106) /* Last Month */
    and
    CONVERT(varchar,dateadd(d,-(day(getdate())),getdate()),106)

  • How to create report which includes records of current month and last 7 days of previous month.

    Hi Experts,
    I need to create a report which includes records of current month and last 7 days of previous month.
    I will get records of current month by this formula :- month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate)
    Please tell me how to add the records of last 7 days of previous Month for the same report.
    Thanks in Advance.

    Hi Ajay,
    If you have more than a year data in your database then your formula will return wrong results. ie. If your data consist of 2012,2013,2014 data then below formula will return all 8th month data irrespective of year. So, you need to check year also here
    month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate)  and
    Year({PROBSUMMARYM1.OPEN_TIME})=Year(currentdate)
    Now add Abhilash second statement in OR so, your formula should look like :
    (month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate)  and
    Year({PROBSUMMARYM1.OPEN_TIME})=Year(currentdate))
    OR
    Date({PROBSUMMARYM1.OPEN_TIME}) IN [DateAdd('d',-7,Maximum(LastFullMonth)), Maximum(LastFullMonth)
    -Sastry

Maybe you are looking for