YTD, MTD, Prior Year, Prior Month calculations in SAP BW Universe

I am finding the SAP BW based universe a totally different animal so far and my question comes from my inexperience in this domain.
In a normal universe, one can use CASE Statement and Calendar or Time table to help do these calculations. Since BW based universes are based on a super BEx query, how are these calculations done in the universe? Are these calculations done in the BEx query itself?
Are there any standards of what should be handled on the BEx side vs. what should be handled on the Universe side?
Also, what's the syntax of a CASE statment or using Substring (or similar function) in a BW universe?
Thanks!

Hi,
You can define calculated measures in OLAP universes using MDX language.
To define a Calculated Measure, users must create manually new Measures in the Universe.
Calculated Measures definitions are using MDX functions embedded in XML tags.
In order to create calculated measures, users must to create pure MDX expression emclosed in XML tags: <EXPRESSION></EXPRESSION>
In this new expression, we authorize to use any Designer function such as:
u2022     @SELECT
u2022     @PROMPT
u2022     @VARIABLE
The check integrity will validate the XML syntax and any of the Designer functions described above.
No MDX parser is provided in this version of Universe Designer.
This paragraph describes how to define calculated measures in MDX and using @Select and @Prompt functions.
CASE statement is not supported in MDX but you can use IIF statement instead of.
It is important to notice that the result of a calculated measure/member in SAP BW (using MDX) must be numeric due to a current limitation f the SAP MDX engine.
Here is 2 samples of an MDX expression using YTD:
    <EXPRESSION>
SUM(YTD(@Select(Key Figures\Billed Quantity
</EXPRESSION>
    <EXPRESSION>
SUM(YTD([Measures].[D3B1M57O3MN5499LF2X9UNHKA]))
</EXPRESSION>
Regards,
Didier

Similar Messages

  • Year and Month calculation

    Hi
    I have created a report with two prompts, they are "Enter Start date:" and "Enter End date:" where i take date values from a calendar while prompting.
    For example:
    Start date = 10/11/2003
    End date = 10/10/2003
    If i want to display the End date means, i ll use UserResponse("Enter End Date:") in the webi reports. What should i do to calculate Year and Month from this user response value,
    i used these calculations below, but it is not working, showing me #ERROR message.
    1) ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy")     =  #ERROR
    2) FormatDate(ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy");"dd/MM/yyyy")     = #ERROR
    3) Year(UserResponse("Enter End Date:")   = The expression or sub-expression at position 6 in the 'Year' function uses an    invalid data type. (WIS 10037)
    4) FormatDate(ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy  hh:mm:ss A");"MM/dd/yyyy") =#ERROR
    so help me how to get the year and month values from prompts ?
    Thanks
    Dineshkumar

    to get the Month Value and year value in Webi
    month name
    =Month(ToDate(UserResponse("Enter End Date:");""))
    month number of the year
    =MonthNumberOfYear(ToDate(UserResponse("Enter End Date:");""))
    to get the Year Value
    =Year(ToDate(UserResponse("Enter End Date:");""))
    good luck

  • Previous and Prior Year Date Values

    How do I get the Previous, Prior year month and Prior year previous month values from a given date?
    Ex: Input would be: 05/01/2008
    The output should be:
    05/01/2008 - Current Month
    04/01/2008 - Previous Month for the Current Year
    05/01/2007 - Prior year current Month
    04/01/2007 - Prior Year Previous Month
    Please let me know..

    Hi,
    Then you'll probably do a self-join. In one copy of the table, you'll get the data from date d1, and in the other copy, you'll get the data from date ADD_MONTHS (d1, -12).
    If, ultimately, you are going to show four sets of figures (from four different rows representing four different dates) on the same output line, then you may find it more convenient to do a pivot rather than a self-join. Search for the buzz word "pivot" and you'll get lots of examples. You might start by selecting four rows:
    WHERE   dt IN
            ( d1
            , ADD_MONTHS (d1, -1)
            , ADD_MONTHS (d1, -12)
            , ADD_MONTHS (d1, -13)
            ) ...and then pivoting that data into four columns:
    SELECT  ...
    ,       MAX (CASE WHEN dt = d1                   THEN val END) AS this_month
    ,       MAX (CASE WHEN dt = ADD_MONTHS (d1, -1)  THEN val END) AS one_month_ago
    ,       MAX (CASE WHEN dt = ADD_MONTHS (d1, -12) THEN val END) AS one_year_ago
    ,       MAX (CASE WHEN dt = ADD_MONTHS (d1, -13) THEN val END) AS thirteen_months_ago
    ...

  • Prior Year YTD and MTD Sales Figure

    Hi,
    I am working on a report where I need to YTD  and MTD figure for current and previous year:-
    I have followed following steps for current year MTD and YTD figures:-
    Create 3 Date variables for Sales on Date with manual input, MTD and YTD on Date characetristics with Customer Exit input. After that I created 3 RKF where I restricted Sales value by each of these date variables.
    Now my question is, Do I need to create two more variables for Prior year MTD and YTD figures with customer exit and then create two more RKF's wherein I will restrict Sales figure with respective variable.
    Is that correct?
    Regards

    Hi,
    you can eighter use the -365 preset  but i suggest creating  2 seerate variables to avoid problems.
    regards
    Ashwin

  • YTD & YTD Prior Year, MTD & MTD Priod Year

    I have to develop a comparison of YTD sales with YTD last year Sales.
    I have developed the YTD formula which was an easy one. How can I develop the YTD prior year.
    Let say I select the day 31-March-2013 so I need the YTD Prior year which is the sales till 31-March-2012.

    Store the selected date in a presentation variable and replace current_date in the below format:
    TIMESTAMPADD(SQL_TSI_YEAR, -1, Current_Date)
    Pls mark if correct/helpful.

  • 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'.

  • 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

  • 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

  • Monthly Sales Report - Prior year comparison

    I am created a monthly sales report for Sales in Crystal 2011. I have a parameter prompting for a date e.g. 02/01/2014 to 02/28/2014. I would like to have the sales amounts beside this column for 2013.
    I found this formula but I can only get my results from 2014.Anyone have an idea how I can do this ?
    Thanks,
    debbie
    \\Current Period
    If pwformatdate({OEAUDH.TRANSDATE})
    in date(year(currentdate)-(if month(currentdate)<10 then 1 else 0),10,1)
    to currentdate
    then Amount Forumula
    else 0.00
    \\Prior Year Period
    If pwformatdate({OEAUDH.TRANSDATE})
    in date(year(currentdate)-(if month(currentdate)<10 then 2 else 1),10,1)
    to dateadd('yyyy',-(if month(currentdate)<10 then 2 else 1),currentdate)
    then Amount Formula
    else 0.00
    the parameter for my date is :
    pwformatdate({OEAUDH.TRANSDATE}) >= {?FromDate} AND
    pwformatdate({OEAUDH.TRANSDATE}) <= {?ToDate} AND
    ({ICITEM.ITEMNO}) >= ({?FromItem}) AND
    ({ICITEM.ITEMNO}) <= ({?ToItem}) and
    {OEAUDH.TRANSTYPE} <> 3

    Hi Debbie,
    1) Modify the Record Selection Formula to;
    {OEAUDH.TRANSDATE} IN [cdate(year({?FromDate})-1, Month({?FromDate}), day({?FromDate})) TO cdate(year({?ToDate})-1, Month({?ToDate}), day({?ToDate}))]
    OR
    {OEAUDH.TRANSDATE} IN [{?FromDate} TO {?ToDate}]
    This should give you current and previous year's data for the period chosen by the user.
    2) Assuming you have a group on the Date field set to print for each year, simply create a running total from the Field Explorer.
    Name it Current Year.
    Choose 'Sales Amount' as the field to Summarize.
    Choose 'Sum' as the Summary Operation.
    Under 'Evaluate', select 'use a formula' and use this code:
    date_field IN
    [cdate(year({?FromDate}), Month({?FromDate}), day({?FromDate})) TO cdate(year({?ToDate}), Month({?ToDate}), day({?ToDate}))]
    Set it to Reset at each Group For Year
    3) Create another Running Total and call it 'Previous Year'.
    Everything remains the same from Step 2 except the evaluate formula:
    date_field IN
    [cdate(year({?FromDate})-1, Month({?FromDate}), day({?FromDate})) TO cdate(year({?ToDate})-1, Month({?ToDate}), day({?ToDate}))]
    Hope this helps.
    -Abhilash

  • 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'.

  • 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

  • Time series questions - how to do AGO function for prior year end

    Question on how to perform the following calculation in OBIEE:
    I need to create a time series calculation that will calculate a metric as of Dec prior year. For example, my users will select Mar 2010. I want to show the amount for Mar 10 as well as the amount for Dec 09. If the select Jun 10, I will show them the amount for that month as well as Dec 09.
    Is there a way to do an AGO function that will give me this value? I can't use a filter calculation on my column because filter on the period will exclude these records

    Thanks John. Your suggestions seems promising but I'm having issues when I tried it out. I am receiving the following error message:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 22046] To use AGO function, the query level ('Fiscal Period, Prior Fiscal Year End Date') must be a static level. (HY000)
    What I did was create a new level off my Fiscal Time dimension which is a child of Total. I tried creating my AGO calculation using this level but received that error message in Asnwers. Any ideas on what I may be doing wrong?

  • How to calculate Prior Year To Date in SSRS

    Hi,
    I've been developing reports in Crystal for a while. The new ERP software we have just purchased uses SSRS for all of their reports. I just started converting the crystal reports to SSRS. I can't seem to find an easy way to do a calculation for Prior Year
    to Date or Prior Year Month to Date in SSRS. Can somebody help me?
    Thanks,
    Cindy

    Your best bet would be to use a calendar table in the TSQL queries. I wrote an article on them here: http://social.technet.microsoft.com/wiki/contents/articles/29260.tsql-calendar-functions-and-tables.aspx
    Alternatively you can use a formula like:
    =DateValue(DATEADD(DateInterval.Day,1-DATEPART(DateInterval.DayOfYear,NOW()),Now()))
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • YTD & MTD day wise while input is month

    Hi,
    In a report I have to provide selection as a month & plant.
    Output should contain day wise sales detail with YTD & MTD.
    I am not getting how to calculate YTD & MTD day wise while selection input is Month.
    Plz suggest me wt to do.
    Regards,
    Kiran

    Hi,
    Check in SDN
    MTD and YTD fig calculations
    It works based on SY-DATUM.
    * First Month Of Current Fiscal year comment*
        WHEN 'FMYEAR'.
    LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZMONTH'.
          CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
                 EXPORTING
                   i_date               = sy-datum
    *         I_MONMIT             = 00
                   i_periv              = 'V3'
                IMPORTING
                  e_buper              =  zbuper
                  e_gjahr              =  zbdatj.
          CLEAR: l_s_range.
          l_s_range-low+4(2) = '04'.
          l_s_range-low+0(4) = zbdatj.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
         ENDLOOP.
    Note: In the above code  I passed i_date = sy-datum, so you pass your month as input for  i_date.
    i.e. Fix the DD = '01'  and concatename your Input month with DD teh you get YYYYMMDD so pass that to i_date.
    Thanks
    Reddy
    Edited by: Surendra Reddy on Feb 24, 2009 5:50 AM

  • Month to Date and Year to date calculation

    Hello Experts,
    It would be great If you could provide the formula to implement in BO universe or in the Reporting level for the below requirement.
    MTD, LastMonth, Year to Date, Last to LastMonth and examples are below.
    Last Week:
    Eg: Monday through Sunday
    Description: Based on Todayu2019s date, select the Monday of the previous week for the start date and Sunday will be the end date.
    Example:
    If Today is May 22, 2009
    The result would be, Monday = May 11, 2009, Sunday = May 17, 2009
    MTD:
    If Today is May 22, 2009
    I need a result MTD = May 1, 2009 u2013 May 21, 2009
    LastMonth:
    If Today is May 22, 2009
    I need a result LastMaont = April 1, 2009 u2013 April 30, 2009
    Last to LastMonth:
    If Today is May 22, 2009
    I need a result LastMaont = March 1, 2009 u2013 March 31, 2009
    Thank you.

    Nisniki,
    Here are the methods using WebI:
    MTD: 
    Create a local variable "MTD Start"
    =RelativeDate(LastDayOfMonth(RelativeDate(CurrentDate();-30));1)
    Create a local variable "MTD End"
    =currentdate()
    LastMonth
    =LastDayOfMonth(RelativeDate(CurrentDate();-30))
    Year to Date
    create a local variable "YTD Begin"
    =ToDate("01/01/"+FormatNumber(Year(CurrentDate());"####");"mm/dd/yyyy")
    (reuse "MTD End" or build a "YTD End" variable same as "MTD End")
    Last to LastMonth
    (similiar to MTD, but using "60" versus "30" to move back two months versus moving back 1 month.
    To perform this stuff in the universe requires an understanding of the SQL syntax for the paricular vendor your are working with.  ANSI SQL agrees to represent and compute dates uniformly, however, the functions to make it happen varies by the vendor.
    Thanks,
    John

Maybe you are looking for

  • Safari 10.5.7 Quit unexpectedly

    Using Safari Snow Leopard, when browsing on the internet getting error message saying Safari Quit Safari quit unexpectedly Have tried, removing plist from Safari folder in Library removing plugins and extensions uninstalling and reinstalling safari P

  • Using JSF in search engine.

    Hi, I am implementing a search engine. I want to use jsf for for the UI part. I have few queries in this regard. - Has anybody used jsf for the same? - Since the search result may contain any number of result, then it is not good to first load all th

  • Doubt in tables for Graphs and Charts

    Hi all I have finished with the creation of bar graph and pie graph for anothe application but iam unable to get the tables that displays the data for the graphs... Also the pie graph and bar graph are coming at a stretch i donot have the option of s

  • Rendering XML output (with large number of columns) to browser breaks

    We have a stored procedure in our database which returns a cursor with over 400 columns.  When we call the stored procedure from within the QT (using mode FixedQueryWithOutput), it renders just fine and very quickly in CSV format.  however, when we a

  • Howto batch rename .mts files ?

    Hello. I have a Panasonic Lumix DMC-FT2 which I use as my video camera. I have set it to save the files as .mts, which is the AVCHD file format. My problem is that when importing these files into iMovie I do not get an option to rename the files so t