Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

Function Ago does not work

Received Response
152
Views
20
Comments
2»

Answers

  • Rank 3 - Community Apprentice

    Thank you for your effort,

    I need to check it deeply.

    I will let you know on Monday.

  • Rank 8 - Analytics Strategist

    Correct ... my mistake ... wasn't reading it right ... needs the time hierarchy level not SQL_TSI ... @Christian Berg - I ain't perfect!  lol ... good catch!

  • Rank 8 - Analytics Strategist

    The SampleApp (v506) has the examples you are looking for ... it has dynamic and fixed ... if you don't have the VM, I can fire mine up after work today and post the details (RPD) from these ..

    Capture.PNG

  • Rank 10 - Analytics Guru

    No worries I just wanted to be clear on things as there's already many confusions flying around in here.

    Anyways I'm with you on the SampleApp track as there's tons of examples in there and it's such a basic functionality that the hickup must lie in a bizarre RPD config or another.

    Probably something like derived calc (post-agg) versus physical mapping calc (pre-agg).

  • Rank 3 - Community Apprentice

    Okay here we go:

    on first screen column1 and column2 and my measures which we're discussing. As you can see both show the same value which is obviously wrong.

    Additionally I added two other measures (not connected with this topic) that show correct values.

    screen2.jpg

    And for the record I'm putting how these measures look in admin tool:

    screen1.jpg

    Honestly I don't know what I'm doing wrong.

    I decided to do in ETL proper calculated fields and I think it's gonna solve my problem.

  • Rank 6 - Analytics Lead

    Hello,

    You could everything you want in the ETL process, however, i dont know why you got the same problem, I answered you about the model in the RPD, and whats about the results, and I didn't have any problem, if you please give me an screenshoot about oyu BMM and Physical Layer.

    structure1.png

    Result1.png

    Kind Regards,

  • Rank 8 - Analytics Strategist

    Don't do the case statement with your ago() ... just base it on the logical column that already evaluates the case ... also since you are using logical columns on logical columns, @Christian Berg's comment of "

    Probably something like derived calc (post-agg) versus physical mapping calc (pre-agg)" is starting to take form as to why this isn't working the way you expect it to.

    You'vew already started in the direction I would point you - back to the database.  I wouldn't precalculate the prior value though (in case you have historical restatements happeing) ... rather my time dimension would have the prior period (LY, LM, YESTERDAY) keys represented on each row.   Then you can alias\ your fact multiple times and join one to the base (current date)key and the rest to the historical keys.  So now the user picks current period, they also can have on the same row LY, LM, YESTERDAY ....

  • Rank 3 - Community Apprentice

    Don't do the case statement with your ago()

    I guess that's the reason why it is not working, but why? Is it forbidden to do case statem with Ago function? I didn't know that before.

    You'vew already started in the direction I would point you - back to the database. 

    Yes, that's what I am going to do.

    @cesar.advincula.o

    It's just standard model. This fact has relationship to dim_time in physical model and BMM as well and that's it.

  • Rank 3 - Community Apprentice

    I'd agree with @Thomas Dodds, you should have a column in the RPD that does your CASE statement then have another column where you do the ago and reference the name of that column so instead of

    ago(case when x then 1 end)

    You'd have

    ago("Fact"."Case",1)

    A lot cleaner and means that the aggregation of the column is done before it attempts the AGO function.

    I know you've said that some of your AGO columns work but it is probably worth the time to look at the basic structure and dimension data behind your hierarchy:

    1. Make sure that at each level of your time dimension hierarchy you have a unique number version of the week in the database i.e. 201605 and use this as your chronological key

    2. Look at the content level of your fact table logical source against the time dimension, make sure it's pointing at the right level (most likely Day or Detail)

  • Rank 6 - Analytics Lead

    Hello,

    Return to your first post, you say that you have two measures:

    "Number available" :                               cast (count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double)

    "Number available previous period": Ago( cast (count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double) , 1)

    And also I asked you about the model because the model is the key for your requirement, and you said to me that is a standard model

    the "f_Customer_Demo" is your "Fact" and Period is your "Time Dimension",

    I mean you have the model like this, its what I understand:

    Fcts.png

    Thats right?

    There is no problem if you use AGO Function with a case statement in measure, if your measure if part of the FACT table, the problem its when you got the measure from the DIMENSION table.

    Now, lets go to your solution, with the scenary of your requirements:

    1. Criteria Tab:

       Criteria.png

    2. Formula by Each column:

    Customer.png

    Customer_Name.png

    number_Available.png

    Cast_Count.png

       cast_Ago.png

           PeriodMonth.png

             PeriodYear.png

    3. Database:

        Data.png

    4. Structure for all columns:


           Remember the logic that you are using:


             "Number available" :                               cast (count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double)

             "Number available previous period": Ago( cast (count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double) , 1)

    Analyze:

           20151001:

                  Cast Count column which is "(count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double)", return 2.

                  Cast Count AGO column which is" Ago( cast (count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double) , 1)", return 0.

           20151101:

                  Cast Count column which is "(count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double)", return 2.

                  Cast Count AGO column which is" Ago( cast (count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double) , 1)", return 2.

           20151201:

                  Cast Count column which is "(count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double)", return 5.

                  Cast Count AGO column which is" Ago( cast (count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double) , 1)", return 2.

           20160101:

                  Cast Count column which is "(count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double)", return 0.

                  Cast Count AGO column which is" Ago( cast (count (distinct  case  when "XXX"."Customers"."available" > 0 then  "XXX"."Customers"."ID" else null end) as double) , 1)", return 5.

           

               Structures.png

    Note: You could apply this formula for your RPD also, you will get the same results.

    Kind Regards,

Welcome!

It looks like you're new here. Sign in or register to get started.