views:

137

answers:

2

Hi all. I've just begun diving into data warehousing and I have one question that I just can't seem to figure out.

I have a business which has ten stores, each with a certain employees. In my data warehouse I have a dimension representing the store. The employee dimension is a SCD, with a column for start/end, and the store at which the employee is working.

My fact table is based on suggestions the employees give (anonymously) to the store managers. This table contains the suggestion type (cleanliness, salary issue, etc), the date it was submitted (foreign keyed to a Time dimension table), and the store at which it was submitted.

What I want to do is create a report showing the ratio of the number of suggestions to the number of employees in a given year. Because the number of employees changes periodically I just can't do a simple query for the total number of employees.

Unfortunately I've searched the web quite a bit trying to find a solution but the majority of the examples are retail based sales, which is different from what I'm trying to do.

Any help would be appreciated. I do have the AdventureWorksDW installed on my machine so I can use that as a point of reference if anyone offers a suggestion using that.

Thanks in advance!

A: 

The slowly changing dimension should have a natural key that identifies the source of the row (otherwise how would it know what to compare to detect changes). This should be constant amongst all iterations of the dimension. You can get a count of employees by computing a distinct count of the natural key.

Edit: If your transaction table (suggestion) has a date on it, a distinct count of employees grouped by a computed function of the suggestion date (e.g. datepart (yy, s.SuggestionDate)) and the business unit should do it. You don't need to worry about the date on the employee dimension as the applicable row should join directly to the transaction table.

ConcernedOfTunbridgeWells
I do have a natural key on the employee table. The biggest problem is getting a count of employees for a particular business unit for a given time period when querying against the cube. If a schema is required please let me know and I'll post something
bdowden
A: 

Add another fact table for number of Employees in each store for each month -- you could use max number for the month. Then average months for the year, use this as "number of employees in a year".

Load your new fact table at the end of each month. The new table would look like:

fact table: EmployeeCount

KeyEmployeeCount int -- surrogate key

KeyDate int -- FK to date dimension, point to last day of a month

KeyStore int -- FK to store dimension

NumberOfEmployes int -- (max) number of employees for the month in a given store

If you need a finer resolution, use "per week" or even "per day". The main idea is to average the NumberOfEmployes measure for a given store over the year.

Damir Sudarevic