I’m about to design a data warehouse and a cube with a product dimension and a sales fact table. The product dimension is a SCD (type 2).
Lets say the data in the product dimension looks like this the first year:
Name | Product Group | Year A | A | 2011 B | A | 2011 C | B | 2011
and like this the second year:
Name | Product Group | Year A | A | 2012 B | B | 2012 C | C | 2012
as you can see some of the products has changed product group between 2011 and 2012.
In the cube I want to ask two types of questions:
The easy one: How much did we sell for in each product group in 2011.
The hard one: How much did we sell for in each product group in 2011 if the products belonged to the product groups they have in 2012.
How would you design the warehouse and the cube do accomplish this?
Thanks!
Ps. I'm using SQL Server 2012
This can be treated as a type 3 SCD. Adding a column [Product Group 2011] allows answering these types of what-if questions.
Name | Product Group | Product Group 2011 | Year
A | A | A | 2012
B | B | A | 2012
C | C | B | 2012
An alternative is to add a durable key to the product dimension and the sales fact.
id | dur_id | Name | Product Group | Year
1 | 1 | A | A | 2012
2 | 2 | B | B | 2012
3 | 3 | C | C | 2012
4 | 1 | A | A | 2012
5 | 2 | B | B | 2012
6 | 3 | C | C | 2012
Then you can join from the SALES fact to the PRODUCT dimesion on the dur_id, just remember to restrict based off of the dimension Year.
For SSAS, you could load in "duplicate" fact rows (i.e. the 2011 and 2012 fact rows associated with 2011, and again associated with 2012) You'd then need to make 2012 the default member for the [Year] attribute hierarchy, and prevent roll-ups that don't specify the year.