If I understand the desired results correctly, the corresponding SQL would be the following:
Code:
select 'ALL' as agg_name, sum(profit) as profit
from
(select contract, sum(profit) as profit
from
(select contract, max(profit) as profit
from products
group by contract
)
group by contract
);
select contract, sum(profit) as profit
from
(select contract, max(profit) as profit
from products
group by contract
)
group by contract;
select product_group, sum(profit) as profit
from
(select product_group, max(profit) as profit
from products
group by contract, product_group
)
group by product_group;
select product, sum(profit) as profit
from
(select product, max(profit) as profit
from products
group by contract, product_group, product
)
group by product;
giving the following results:
Code:
ALL PROFIT
ALL 4000
CONTRACT PROFIT
5000 1000
5001 2000
5002 1000
PRODUCT_GROUP PROFIT
DVD 2000
Stream 4000
PRODUCT PROFIT
48th rental 2000
TV 2000
VOD 3000
Assuming that's correct, it exposes that these measures are non-additive on a single hiearchy. So my initial thought would be to investigate separate hierarchies within the same PRODUCT dimension. It may be that a calculated measure can then define what you're looking for. Another idea may be to define separate fact tables (separate cubes) and create a virtual cube combining the summarized results.
dlgrasse