Wednesday, March 7, 2012

Fact Snapshot Table Question

Hello All,

I have a Snapshot Fact table that shows data on a monthly basis. Each person has a row for each month.
But now I am adding bonus information. The problem is, for each month a person may have received more than one bonus amount and type in a month. For example:
ID Date Bonus Bonus Type
1000 1/1/2000 $5,000 Team
1000 1/5/2000 $ 500 GoodJob
1000 1/7/2000 $ 250 Incentive

What is the best way to have multiple bonuses and their amounts in the fact table, (when the fact table currently has a single row per employee, per month)?


Thank you for the help.

-Gumbatman

Assuming that you are using SSAS 2005, Just keep this information in it's own fact table and add that to the cube as another measure group.|||

Darren,

Thank you for the reply, but I am not 100% clear on what you mean (my issue, not yours).

I have my main fact table, that is populated each month, for example:

EmployeeID DateKey JobKey GeographicKey 1 20060101 123 455 2 20060101 3247 9898 3 20060101 9870 2444 1 20060201 987 455 2 20060201 3247 9898 3 20060201 9870 2444

If I now have the bonus information as a separate table, how would I link them in order to add the bonus information as a Measure Group?

Do I need to have the JobKey and GeographicKeys in the Bonus fact table to do my slicing by dimensions (seems redundant)?

Taking a guess, I assume my Bonus fact table should it look something like this:

EmployeeID DateKey BonusAmount BonusKey 1 20060101 500 55 1 20060101 1000 42 1 20060101 250 3 3 20060101 500 55 2 20060201 250 68

My assumption is to link the two fact tables by DateKey and EmployeeID.

Thank you for the help. I've been trying to get my brain around this for a while.

|||

Having different granularities can make things a bit harder to get your head around. If you have a look at the Adventure Works cube you will see that the sales targets measure group is probably similar to bonus fact table we are talking about here.

The answer to your question hinges around how you want to see the data come out like the following, with the bonus essentially repeated for each unrelated attribute (ie Job and Geography).

EmployeeID DateKey JobKey GeographicKey Bonus 1 20060101 123 455 2000 2 20060101 3247 9898 250 3 20060101 9870 2444 500 1 20060201 987 455 2000 2 20060201 3247 9898 250 3 20060201 9870 2444

500

Then simply adding the bonus fact table to the cube and setting up the dimension relationships tab so that only the date and employee dimensions are related to the bonus amounts should be enough. You can also change a setting on the measure group so that if someone drills down by an unrelated dimension then the bonus amount returns null.

Those are the two default options, the only other option I can think of would be to devise an allocation mechanism to divide the bonus between the unrelated attributes like Job and Geography which would involve either extra work in the ETL phase or calculations in the MDX script.

|||

Darren,

Thank you so much for the answers and explanations. I still need to get my head around how the Sales Targets measure group is related, but it certainly seems to be what I was looking for.

I really appreciate you taking the time to answer this for me. You've saved me lots of time and work trying to figure it out on my own (which probably wouldn't have happened).

-Gumbatman

|||

Darren,

I've tried implementing this, but I am not doing something correctly.

I have my Fact table:

RowKey EmployeeKey Date 1 500 20061031 2 600 20061031 3 700 20061031 4 500 20061130 5 600 20061130 6 700 20061130

And my Bonus Fact Table, which references the RowKey:

RowKey BonusAmount Date 1 250 20061031 1 700 20061031 6 1000 20061130 6 2000 20061130

As you can see, Employee 500 got two bonuses in October and Employee 700 got two bonuses in November.

I linked the two Fact tables in the Data Source View (using RowKey) and added a new Measure Group. In the Dimensions tab, I can only connect the Date to the Time Dimension. I don't know how to connect the tables other than that since the Bonus Fact table doesn't have those dimensions.

When I Browse the cube, the Bonus amounts do show over time, but the total populates all the rows. For example,

Period 1 Period 2 Period 3 Midwest 50,000 98,000 45,000 Northeast 50,000 98,000 45,000 Southwest 50,000 98,000 45,000

How do I connect the two fact tables so I can use all the Dimensions that are already connected to the main Fact table? I did try the many-to-many connection but that didn't help either.

Thank you for the help.

-Gumbatman

No comments:

Post a Comment