I'm building a Human Resources OLAP schema, and I'm having lots of trouble calculating headcount. It sounds simple enough, but it's actually quite tricky following OLAPs fact table design and handling distinct employees. Essentially I'm following the following model laid out by Ralph Kimball. I have an Employee table that represents the transactions performed on an employee, and then I have a Employment table that is the fact table.
In Ralph's example he only calculates the fact table on a per month basis (ie month_key), but in my table I can calculate either by month, quarter, year, etc. At the month level everything works fine because there are no duplicate entries for a single employee. But, move up the hierarchy to quarter or year and a single employee gets double counted or more. For example for 1 year if an employee is employed all 12 months if you sum up his records he'll be counted 12 times!
The problem is that you can't aggregate the numbers in the table because of these duplicate entries. I've tried several other methods, but none of them really work reliably. But I thought about it and figured I could create aggregate tables for each level in the Employment Date. One table that used for year, one table that used for quarters, etc. That way my loading procedures could decide how to count employees at each level, and make sure only one employee is rolled up. And my logical structure of the data remains intact. From a query perspective I can still think of my data in years, quarters, months, etc.
Is this an appropriate use of aggregate tables? I've never heard of anyone using them for this purpose. I'm not using it for performance boost, but I'm using it to normalize the data and make sure everything is loaded in a way that can be aggregated without concern about duplicates. My queries won't change will they? I still be able to do something like:
select [Work Location] on ROWS, [Measures].[headcount] on COLUMNS from [Employment] where [EmploymentDate].[2014]
And
select [Work Location] on ROWS, [Measures].[headcount] on COLUMNS from [Employment] where [EmploymentDate].[2014].[5]
And Mondrian will use the appropriate table to pull the data from without me having to specify it in the query.