Grand Total Dimension Hierarchy Example


You might have a product dimensional hierarchy with levels TotalProducts (grand total level), Brands, and Products. Additionally, there might be a column called Revenue that is defined with a default aggregation rule of Sum. You can then create a logical column, AllProductRevenue, that uses Revenue as its source (as specified in the General tab of the Logical Column dialog). Now drag AllProductRevenue to the grand total level. Each query that includes this column will return the total revenue for all products. The value is returned regardless of any constraints on Brands or Products. If you have constraints on columns in other tables, the grand total is limited to the scope of the query. For example, if the scope of the query asks for data from 1999 and 2000, the grand total product revenue is for all products sold in 1999 and 2000.
If you have three products, A, B, and C with total revenues of 100, 200, and 300 respectively, then the grand total product revenue is 600 (the sum of each product's revenue). If you have set up a repository as described in this example, the following query produces the results listed:
select product, productrevenue, allproductrevenue
from sales_subject_area
where product in 'A' or 'B'
PRODUCT  PRODUCTREVENUE   ALLPRODUCTREVENUE 
A        100              600 
B        200              600 
In this example, the AllProductRevenue column will always return a value of 600, regardless of the products the query constrains on.

No comments:

Post a Comment

Popular Posts