This document contains how the query differs before and after implementing Aggregate Awareness.

Aggregate Awareness in Universe

Lets say I have two tables customer and daily fact  with below data:

If I create the report of customers daily sales, it will join customer and daily fact table using cid column and will give me 24 rows of data.

But if my requirement is to create only quarterly sales or just monthly sales than the data will still traverse through 24 rows of daily fact table.

For eg.  Monthly sales will give me 12 rows of data while quarterly will be 4 rows of data. But this is still getting data from detail fact which has 24 rows, which if hold million facts can slow down the performance.

So we create materialised views or summary tables in our database for better performance.

And I created monthly and quarterly fact in my sample database. Below are the aggregated tables that I can use in my universe.


Now, the question is, we have aggregate tables but how to use the same in my universe based on user queries dynamically.

Aggregate awareness functionality will help me in achieving the same.

It is a two step process:

  1. 1.    Use aggregate aware function in objects that needs to be made aggregate aware.
    2 .   Setting incompatibilities of objects with tables in aggregate navigation section.

Below is the structure of my universe now:

Now, I have made time dimensions i.e. Sales Dt, Sales Month and Sales Qtr and measue Sales as aggregate aware.

Aggregate function has syntax like:

@Aggregate_Aware(sum(aggregate table1),…,sum(aggregate tableN)) Defines a measure object using precalculated aggregate tables.

Where table1 is highly aggregated(in our case quarterly fact),……..and tableN is the least aggregate or    detailed one(in our case daily fact)


If you observe the definition in the select statement of Sales measure here, it is from highly aggregated table to detail one , same is done for the dimension table as well.

Now month is present in only two tables, hence only monthly and daily fact is used.

Sales Qtr object, quarter is present in all three fact tables; hence all the three are used.

We have used aggregate function in these tables, so we hope that system automatically will decide which table to refer dynamically, when a user selects or tries to run a query.

That means if user wants daily data than daily fact should be used, if monthly than monthly fact or if quarterly sales than quarterly fact.

Aggregate Navigation:-

Now, we have to set the incompatibilities.

This is done from Aggregate Navigation section under tools, in menu bar.

We have to make objects incompatible to tables.

For eg. Sales dt is incompatible to quarter and months table, similarly Sales month object is incompatible to quarter table.

You have to click the table and check the box in front of object to make it incompatible with the selected table.


Lets see how the queries behave, when you select different set of objects:

Scenario 1:

I selected customer name and sales, and if you see the below query , it is behaving same as the one i expect it, as it is taking data from quarterly fact table.

Scenario 2:  I added sales month object to it, and will remove quarter object.(it should only now point to monthly facts)

And if you observe, it is now using monthly facts only.

Scenario3:  Using sales dt object.

Note: if aggregate navigation have not been used than the measure sales will always point to quarterly fact, even if you use sales dt object in your query, which is wrong behavior.

Also it is required to link aggregate fact to dimension tables, else it would fetch Cartesian product for table which are not joined. In efashion universe the aggregate table are not joined to other because the table itself has all the dimension objects, which is not always the case. In real time aggregate fact will hold aggregate measures and foreign keys of dimension table only, that is why it has to be joined to dimension tables.

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. Shahnawaz Sayyed

    To Understand Aggregate Awareness I had visited so many links and tutorials but your document helped a lot.

    Such a simple way of explaining it.

    Thanks! for the Doc

    (0) 
  2. Mark Prosser

    A nice starter document to explain the fundamentals of aggregate awareness. This can really come into its own when you have large dimensions and can use aggregate awareness on your dimensions too. The other important thing to discuss when talking about aggregate awareness is to either state the assumption that contexts are set up correctly or to bring it into the discussion.

    (0) 
    1. Samata Beesabattula Post author

      Hello Venkat,

      My intention is not to copy and get the credit, It’s just a knowledge sharing….. be positive, think positive…..it’s not copying….its sharing the knowledge to SCN users.

      Thanks for spending your valuable time for the above comment.

      Regards,

      Samatha B

      (0) 
      1. Venkat Patnaik

        Hi Samatha,

        Please don’t take it otherwise. My intention was avoid redundancy of content and at the same time credit to the person who actually posted it. Instead of posting the whole content only the link could have been shared which will in no way impact knowledge sharing and will also maintain copyrights.

        Thank you for your feedback.

        Regards,

        Venkat

        (0) 

Leave a Reply