Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

how to add department AND city (both with different start date) to Employee dimension

$
0
0

Hello, I'm using SQL ser er 2008 R2 Standard

I have created an employee dimension table, with history for department changes SCD:

ID    employee_nr  Dept_startdate     Deparment

With a lookup I add the correct employee record to the fact table.

Now I want to add the employee city to this employee dimension, but it has it's own start date,  city_startdate, so i can track city changes.

How can I add this to the Employee dimension, and how can I make the lookup find the correct dimension record?

Example: Suppose I have employee with ID 12345

City history of employee 12345:

City_startdate   city

2008-01-01       Boston

2010-01-01       New York

Department history of employee 12345:

Dept_startdate    department

2004-12-22         Sales

2006-11-30        Marketing

2010-02-01       Finance

2011-06-01         Marketing

The desired result should be this:

id   date                  city             department

1    2004-12-22      Boston           Sales

2    2006-11-30      Boston           Marketing

3    2010-01-01      New York       Marketing   (here you see that city changed to New york from 2010-01-01, when he still worked at marketing)

4    2010-02-01      New York       Finance

5    2011-06-01      New York        Marketing

Another problem is that city history is started from 2008-01-01, but department history is older, so I want for those older records to have the first (oldest) city record.

Regards, Hennie



Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>