AGO and TODATE functions

I want to use the AGO and TODATE functions to calculate a measure for the selected year and the year before, as well as a year--o date measure, but cannot get it to work. It fails with the following error:
A general error has occurred. [nQSError: 22040] To use TODATE function, the storage level of the query ('[D_TIJD.TIJDKEY]') must be a static level.
I have setup a time dimensions in which I can drill up and down and followed exactly the same steps that were layed out in the Oracle training activity guide, but so far without any luck. From Mark Rittman's articles I learned that using these functions is not as straight forward as one might hink. Does anybody have a working example of this?
Regards,
Paul

To reply to my own question. It appears I got it working, that is, the error message problem is solved, but I still have questions on how to use these functions.
To get it to work, I added the primary key D_TIJD.TIJDKEY at the level of the lowest grain in my dimension (level tab).
What I still wonder is how to make it select the right values. I have the following hierarchy: bookyear - bookperiod - week. A bookperiod contains 4 or 5 weeks (4,4,5 in a quarter), so 12 periods in one year. I defined a measure at period level and another at that level with the ago function, that should return the figures for that same period of the year before. My first question is, whether to go back 12 periods or 52 weeks (which is the lowest grain in my dimension)?
The second question is how to use a combination of TODATE and AGO so that if I calculate the current period (of which only 2 weeks are passed), I also only want to include the same two weeks for that period one year ago in order to make a correct comparison. How do I do that???

Similar Messages

  • Nested Ago and Todate function problem

    Hi,
    in my rpd i have following Time hierarchy:
    Year
    Quarter
    Month
    and a fact table Fact Shop which contains Monthly measure "Number of Hearing Aids Delivered".
    I must calculate PY_QTD, PY_YTD versions of above measure.
    I have tried to use built-in Time Functions Ago and ToDate in the following way:
    PY_QTD
    Todate(Ago("Number of Hearing Aids Delivered",1,"Time.Year"), "Time.Quarter")
    PY_YTD
    Todate(Ago("Number of Hearing Aids Delivered",1,"Time.Year"), "Time.Year")
    but when i check consistency i have error which says approximately "You can nest Ago and ToDate functions".
    There's another way, to calculate it? Can you help?
    Thanks
    Giancarlo

    So u r referring PY as previous year ;)
    Here u go;
    it’s a combination of AGO and TODATE.
    You create a value – let’s say Sales MTD by just following normal process…then you create a logical column with the following formula AGO (Sales MTD, Month Dim, 12)
    that should give you a MTD measure you’re looking for. I hope this is useful. Just dont use both function in single logical column....use seperate by first creating YTD n then AGO function to create previous year data.
    For ur case use to calculate PY_YTD use below:
    Create logical column
    Aids Delivered YTD with formula as TODATE("Number of Hearing Aids Delivered"), "Time.Year")
    and then create another logical column as
    Aids Delivered PY_YTD with formula as AGO("Aids Delivered YTD","Time.Year",1)
    This will work for sure....

  • Ago and Todate functions very slow

    I have been playing around with the Ago and Todate functions in BI EE (based on data from the Global schema which I imported into BI EE Administrator) but I find these functions very slow to return the data in an Answers report. Has anyone else found this?

    What's the size of the data set?
    Yes, I'm currently experiencing it. Running on a 600-700k rows tables...
    However, there're 2 things that might help:
    a) we're doing development with cache off - enabling cache - makes report come instantly...
    b) make sure the metrics have correct levels set up - i.e. it's sometimes advantageous to have several duplicates of 1 metric just for this purpose...with different levels....
    Please let me know if you find other ways to improve performance...

  • How Achieve timedseries calculations with out using AGO And ToDate function

    Hi,,
    1)
    How Achieve timedseries calculations with out using AGO And ToDate functionion
    this question asking in interview ..is it possible..?
    if yes please response as soon as possible..
    2) i have 2 cloumns Product and value...
    client requirement is they need ranks based on Value ..in dashboard .using dashboard prompt..edit box...if user enter any number (ex :5 ) report should show top 5 ranks if he enter 20 should be top 20 ranks..
    how to achive this ?
    thanks,
    raj

    Consider yor first question:
    1. Yes, we can create timeseries measures without using AGO and TODATE
    1. Create ALIAS of fact tabe in the physical layer
    2. Join the Time id from the ALIAS fact table with the YAGO_MONTH_ID column from your time dimension table (For calculating Year Ago variants) similarly join with MAGO_MONTH_ID column for Month Ago measures.
    3.Pull the ALIAS tables as an additional Logical table source in the Lgical layer
    4.Keep the mapping of the columns from the ALIAS table as its is
    5. For e.g If you pick Revenue from the Year Ago Alias table it will give you the "Prior Year Revenue"
    See if this helps you

  • Generic "AGO" and "TODATE" functions

    Hi, I'd like to find out if it's possible to have "generic" date functionality that applies at whatever date level the user chooses. For example, instead of having:
    Day Sales
    Prior Day Sales
    Year Ago Day Sales
    Week Sales
    Prior Week Sales
    Year Ago Week Sales
    Month Sales
    Prior Month Sales
    Year Ago Month Sales
    Quarter Sales
    Prior Quarter Sales
    Year Ago Quarter Sales
    Year Sales
    Prior Year Sales
    instead I'd like to have:
    Sales
    Prior Period Sales
    Year Ago Period Sales
    It looks like the "AGO" function, for instance, requires the time level to be put in. But I'd rather NOT put a specific time level in - and have that default to whatever the user asks for in the report. i.e. if they put "Jan 2009" in the report then it knows it's at the month level. If they put "Q3 2009" in it would know to do it at the quarter level, etc.
    Is there any way to do this?
    Thanks in advance,
    Scott

    To reply to my own question. It appears I got it working, that is, the error message problem is solved, but I still have questions on how to use these functions.
    To get it to work, I added the primary key D_TIJD.TIJDKEY at the level of the lowest grain in my dimension (level tab).
    What I still wonder is how to make it select the right values. I have the following hierarchy: bookyear - bookperiod - week. A bookperiod contains 4 or 5 weeks (4,4,5 in a quarter), so 12 periods in one year. I defined a measure at period level and another at that level with the ago function, that should return the figures for that same period of the year before. My first question is, whether to go back 12 periods or 52 weeks (which is the lowest grain in my dimension)?
    The second question is how to use a combination of TODATE and AGO so that if I calculate the current period (of which only 2 weeks are passed), I also only want to include the same two weeks for that period one year ago in order to make a correct comparison. How do I do that???

  • Nesting of AGO or TODATE functions with differing level arguments is not supported

    I have a column in BMM which calculates the Year-To-Date Sales. This function uses the ToDate function to caculate the YTD.
    I need to develop another formula column which shows the last-year's YTD.
    I develop this formula in BMM by AGO on the YTD column which already uses a ToDate function.
    In BI Answers when selecting this column, results in the below message:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 22044] Nesting of AGO or TODATE functions with differing level arguments is not supported. (HY000)

    To reply to my own question. It appears I got it working, that is, the error message problem is solved, but I still have questions on how to use these functions.
    To get it to work, I added the primary key D_TIJD.TIJDKEY at the level of the lowest grain in my dimension (level tab).
    What I still wonder is how to make it select the right values. I have the following hierarchy: bookyear - bookperiod - week. A bookperiod contains 4 or 5 weeks (4,4,5 in a quarter), so 12 periods in one year. I defined a measure at period level and another at that level with the ago function, that should return the figures for that same period of the year before. My first question is, whether to go back 12 periods or 52 weeks (which is the lowest grain in my dimension)?
    The second question is how to use a combination of TODATE and AGO so that if I calculate the current period (of which only 2 weeks are passed), I also only want to include the same two weeks for that period one year ago in order to make a correct comparison. How do I do that???

  • How to get Last Year Sales and YTD Sales without using AGO and TODATE?

    Hi all,
    I have got Company and Time dimensions and Sales Fact. My requirement is to get Last Year sales for each company without using AGO function and YTD without using TODATE function. (Due to performance issue as AGO and TODATE do not insert a Cache entry).
    Can someone please help me to achieve my requirement? Thanks in advance.

    Hi Satya,
    Thanks again for your reply. To start with I don't have data for the years 2012 and 2011 to test as I am using SH sample schema from Oracle. I have applied your solution but it does not seem to be working for the previous years like 2000, 2001. My requirement is to have a dashboard prompt "YEAR" and let the user choose whatever year he wants.
    Please have a look at the column formulas of my analysis (As per your solution) :
    ***here B_YEAR is replaced by CALENDAR_YEAR.  
    Amount: "F1 Sales"."Amount"
    AmountYTD:  FILTER("F1 Sales"."Amount" USING "D1 Time"."CALENDAR_YEAR" =YEAR(CURRENT_DATE))
    Amount LY: FILTER("F1 Sales"."Amount" USING "D1 Time"."CALENDAR_YEAR" =YEAR(CURRENT_DATE)-1)and the physical query generated by BI Server: (as you can see I have got a filter CALENDAR_YEAR= 2000)
    WITH
    SAWITH0 AS (select sum(T1074.AMOUNT_SOLD) as c1,
         sum(case  when T1035.CALENDAR_YEAR = TO_NUMBER(TO_CHAR(TO_DATE('2012-05-03' , 'YYYY-MM-DD'), 'yyyy'), '9999') then T1074.AMOUNT_SOLD end ) as c2,
         sum(case  when TO_NUMBER(TO_CHAR(TO_DATE('2012-05-03' , 'YYYY-MM-DD'), 'yyyy'), '9999') - 1 = T1035.CALENDAR_YEAR then T1074.AMOUNT_SOLD end ) as c3,
         T1035.CALENDAR_MONTH_DESC as c4,
         T1035.CALENDAR_YEAR as c5,
         T1035.CALENDAR_MONTH_ID as c6
    from
         TIMES T1035 /* D1 Time */ ,
         SALES T1074 /* F1 Sales */
    where  ( T1035.CALENDAR_YEAR = 2000 and T1035.TIME_ID = T1074.TIME_ID )
    group by T1035.CALENDAR_MONTH_DESC, T1035.CALENDAR_MONTH_ID, T1035.CALENDAR_YEAR)
    select distinct 0 as c1,
         D1.c4 as c2,
         D1.c5 as c3,
         D1.c1 as c4,
         D1.c2 as c5,
         D1.c3 as c6,
         D1.c6 as c7
    from
         SAWITH0 D1
    order by c3, c2 Thanks in advance.

  • Purge Data #error when UserResponse and ToDate function is used in same formula

    Hi,
    I have a formula which works well when there is data but when I purge the webi report I get #Error for the cells wherever I have used UserResponse and ToDate function in the same formula.
    Ex: =FormatDate(ToDate(UserResponse("Enter Modified Date:");"M/dd/yyyy hh:mm:ss a");"MM/dd/yyyy")
    I tired in multiple reports. I get the same error in all reports when i purge the data but when i unpurge and show the reports with data, I won't get any error.
    Is this known issue? If anyone knows the solution. Please answer it.
    (FYI, I am using BO4.0 SP5)
    Thanks.

    Thanks a lot for all your efforts in trying to find the solution to my question but the formula that you had has a error, as you were using commas instead of semicolon. If you want I can change it & it's not a big deal.
    By the way, I have found even better solution.
    Substrings will kill the processing time and we should try to avoid string functions as much as possible. So I used IsError function instead.
    =If IsError(FormatDate(ToDate(UserResponse("Enter Modified Date:");"MM/dd/yyyy hh:mm:ss a");"MM/dd/yyyy")) Then "" Else FormatDate(ToDate(UserResponse("Enter Modified Date:");"MM/dd/yyyy hh:mm:ss a");"MM/dd/yyyy")

  • TODATE Function used on a dimension which is logically snowflaked.

    Guys,
    PLease help me to resolve the below error.Can anone explain why do we get this error and how to resolve it?
    Odbc driver returned an error (SQLExecDirectW).
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 171039483. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 22045] TODATE function is used on a time dimension which is logically snowflaked. (HY000)
    SQL Issued: SELECT "Time"."Fiscal Quarter" saw_0, "Facts - Budget"."Total Operating Expenses" saw_1, "Facts - Actuals"."Total Operating Expenses" saw_2, "Facts - Budget"."Total Operating Expenses"-"Facts - Actuals"."Total Operating Expenses" saw_3, "Facts - Budget"."Total Operating Expenses YTD" saw_4, "Facts - Actuals"."Total Operating Expenses YTD" saw_5, "Facts - Budget"."Total Operating Expenses YTD"-"Facts - Actuals"."Total Operating Expenses YTD" saw_6, AGGREGATE(saw_1 BY ), AGGREGATE(saw_2 BY ), AGGREGATE(saw_3 BY ), AGGREGATE(saw_6 BY ) FROM "Financials - GL Budget and Expenses" WHERE ((Time."Fiscal Quarter" <= VALUEOF(NQ_SESSION."CURRENT_FSCL_QUARTER")) AND (Time."Fiscal Quarter" > VALUEOF(NQ_SESSION."FSCL_QTR_YEAR_AGO"))) AND (("WFS Segments".ORG_NUM = VALUEOF(NQ_SESSION."OU_ORG"))) AND ("GL Segment1"."Hierarchy ID" = 'TTTTT') AND (Time.Status = 'Closed') ORDER BY saw_0
    Thanks in advance...

    AGO and TODATE would only work with 1 physical time table..
    Re: TODATE and AGO function errors in OBIEE
    hope this link may helps you.
    Thanks,
    Chinna

  • SQL for Time Series Functions AGO and YTD

    When we use a time series function such as AGO or TODATE, OBIEE creates 2 physical queries. One query reads the calendar table. The other query reads the fact table without any date filter in the WHERE clause. Then the results of the 2 queries are stitched together. The query on the fact table returns a lot of rows because there is no filter on date.
    Is there a way to force OBIEE to put a filter on the date when performing the physical query on the fact table when using AGO or TODATE?
    Thanks,
    Travis
    v11.1.1.6

    We do have a date filter on the analysis. We need the analysis to show sales for a certain month and sales for that month a year ago, so we use the AGO function. However, it is really slow because it does a physical query on the sales table without filtering on date and then filters the results of that physical query by the dates from the physical query on the calendar table.

  • On the AGO Function need to Create TODATE function with Diff levels - MTD,Q

    Hi All,
    My Basic Requirement is to Create Time Series Function on AAA ie ( Month To Date , Quarter To Date and Year To Date )
    The Logic for the AAA = XXX / Previous 3 Months Revenue.
    we know that we can use the AGO Function to create Previous 3 months Revenue with Month is Level . But the issue is .... i cant use AGO function since i need to perform Year to Date, QTD and MTD upon 'AAA' this OBIEE doesn't permit to use nested time series functions upon varying levels .
    So How can i Resolve the issue ie creation of TODATE function on the AGO Function with Diff levels
    Thanks,
    Swapna S

    hi,
    for your requirement create three repository variables like
    for previous 3 months create repository variable like
    select to_char(sysdate,'yyyymm') -3 from dual;
    for month to date first calculate first day of the month
    select To_Char(Add_Months(Last_Day(Sysdate),-1) + 1,'MM/DD/YYYY') from dual;
    after put a filter in answers date between first date of the present month and current date
    create the same thing for year to date
    calculate first date in the year like following query
    select To_Char(Trunc(Sysdate,'YEAR'),'MM/DD/YYYY') from dual;
    after that apply filter date b/w first date in the year and current date
    i hope it works for your scenario
    Regards
    Naresh
    Edited by: Naresh Meda on Nov 10, 2008 2:08 AM
    Edited by: Naresh Meda on Nov 10, 2008 2:12 AM

  • Ago/Todate Function

    How to make use of AGO/TODATE function in answer not RPD?
    I do not know how to insert data,such as time_level [AGO(expr, time_level, offset) ]

    Hi,
    AGO(<measure_expression>, <level>, <number of period>)
    Where:
    expr is an expression that references at least one measure column.
    time_level is an optional argument that specifies the type of time period, such as quarter, month, or year.
    offset is an integer literal that represents the time shift amount.
    Refer the below example:
    http://www.rittmanmead.com/2007/04/obi-ee-time-dimensions-and-time-series-calculations/
    http://sandybi.wordpress.com/2009/12/08/time-series-caclulations-in-obiee/
    Thanks
    Deva

  • OBIEE 11g time series: regression on ago / todate function ?

    Hello,
    We are testing the migration to OBIEE 11G.
    We are currently in 10.3 version
    We have a problem on AGO / TO_DATE OBIEE functions that returns null results on existing reports.
    In 10.3 version, these functions work properly with the actual TIME dimension.
    Here is how we designed time Dimension:
    TOTAL -> Year -> Quarter -> MONTH -> WEEK -> DATE_KEY, FULL_DATE
    DATE_KEY is a number and referenced as a foreign key on our fact table.
    CREATE TABLE TD_DATE
    +(+
    DATE_KEY NUMBER (11) NOT NULL,
    FULL_DATE DATE
    WEEK NUMBER (2),
    MONTH NUMBER (2),
    QUARTER NUMBER (1)
    YEAR NUMBER (4),
    TOTAL_DATE VARCHAR2 (11 BYTE)
    +)+
    Database version: Oracle 11g
    All elements of the dimension are chronological key (except full date) in order to optimize performance.
    Have you encountered similar problems in inplémentation of AGO / TO_DATE function on version 11g?
    Thanks,
    Romain

    Does a month have always the same number of week and begin with the first day of a week ?
    If it's not the case, your dimension is not good when you make a report on the week grain for a year ago for instance.
    Here a check list:
    http://gerardnico.com/wiki/dat/obiee/ago_todate_configuration#timecalender_dimension_design_verification
    Success
    Nico

  • Bad performance due to the use of AGO and TO_DATE time series functions

    Hi all,
    I'm building an OBI EE Project on top of a 1TB DW, and i'm facing major performance problems due to the use of the AGO and TO_DATE time series functions in some of the Metrics included on the reports. I discovered that when a report with one of those metrics is submited to the DB, the resulting query/explain plan is just awful!... Apparently OBI EE is asking the DB to send everything it needs to do the calculations itself. The CPU cost goes to the roof!
    I've tried new indexes, updated statistics, MV's, but the result remains the same, i.e., if you happen to use AGO or TO_DATE in the report you'll get lousy query time...
    Please advise, if you have come across the same problem.
    Thanks in advance.

    Nico,
    Combining the solution to view the data in dense form (http://gerardnico.com/wiki/dat/obiee/bi_server/design/obiee_densification_design_preservation_dimension), and the use of the lag function (http://gerardnico.com/wiki/dat/obiee/presentation_service/obiee_period_to_period_lag_lead_function) appears to be the best solution for us.
    Thanks very much.

  • When using TODATE function MDX query is not correctly generated

    Essbase 9.3.1.2 and OBIEE 10.1.3.4.1.
    When using TODATE function MDX query is not correctly generated.
    This leads to unexpected values not only on cumulative columns in report (generated with TODATE), but also other columns (calculated with AGO function or directly read from cube) have incorrect values.
    The problem occurs when you filter on a column that is not in the select list. If you filter on just one level of dimension, results are fine. You can filter on multiple dimensions as long as you filter on just one level of each dimension.
    If you filter on two or more levels of one dimension, than results are not correct. In some cases results for TODATE column are all zeros, in some cases it is a random value returned by Essbase (same random value for all rows of that column), and in some cases BI Server returns an error:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. Essbase Error: Network error [10054]: Cannot Send Data (HY000).
    Here is generated MDX code:
    With
    set [Grupe proizvoda2] as '{[Grupe proizvoda].[N4]}'
    set [Grupe proizvoda4] as 'Generate([Grupe proizvoda2], Descendants([Grupe proizvoda].currentmember, [Grupe proizvoda].Generations(4), leaves))'
    set [Segmentacija2] as '{[Segmentacija].[RETAIL]}'
    set [Segmentacija4] as 'Filter(Generate({[Segmentacija2]}, Descendants([Segmentacija].currentmember, [Segmentacija].Generations(4),SELF), ALL), ([Segmentacija].CurrentMember IS [Segmentacija].[AFFLUENT]))'
    set [Vrijeme3] as '{[Vrijeme].[MJESEC_4_2009]}'
    member [Segmentacija].[SegmentacijaCustomGroup]as 'Sum([Segmentacija4])', SOLVE_ORDER = AGGREGATION_SOLVEORDER
    member [Accounts].[MS1] as '(ParallelPeriod([Vrijeme].[Gen3,Vrijeme],2,[Vrijeme].currentmember), [Accounts].[Trosak kapitala])'
    member [Accounts].[MS2] as '(ParallelPeriod([Vrijeme].[Gen3,Vrijeme],1,[Vrijeme].currentmember), [Accounts].[Trosak kapitala])'
    member [Accounts].[MS3] as 'AGGREGATE({PeriodsToDate([Vrijeme].[Gen2,Vrijeme],[Vrijeme].currentmember)}, [Accounts].[Trosak kapitala])'
    select
    { [Accounts].[Trosak kapitala],
    [Accounts].[MS1],
    [Accounts].[MS2],
    [Accounts].[MS3]
    } on columns,
    NON EMPTY {crossjoin ({[Grupe proizvoda4]},{[Vrijeme3]})} properties ANCESTOR_NAMES, GEN_NUMBER on rows
    from [NISE.NISE]
    where ([Segmentacija].[SegmentacijaCustomGroup])
    If you remove part with TODATE function, the results are fine. If you leave TODATE function, OBIEE returns an error mentioned above. If you manually modify variable SOLVE_ORDER and set value to, for example, 100 instead of AGGREGATION_SOLVEORDER, results are OK.
    In all cases when this variable was modified in generated MDX, and query manually executed on Essabse, results were OK. This variable seems to be the possible problem.

    Hi,
    Version is
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE    10.2.0.5.0      Production
    TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    Sorry, in my last post i forgot to mention that i already created a function based index but still it is not using because, there is a UNIQUE constraint on that column.
    Thanks

Maybe you are looking for