Hi All,
I have a cube with a Fact and 3 dimensions.
1. FactP (BuildingKey, Tenantkey, Suitprice, ExecDate, StopBilldate)
2. Building (BuildingKey, ........)
3. Tenant (TenantKey, SuitID, LeasID, ExecDate, StopBilldate)
4. AsOfDate (Regular Date Dimension)
As you see building and tenant are tied to Fact but not AsOfDate. A suite could be occupied by only one tenant(LeasID) at one point of time, over a period few suites can be left vacant or occupied. Now, I have all such data in my fact table but when a user selects a AsOfDate '3/31/2012' in the filter only the cube should return the data which ever is the status of that suite either vacant or occupied, that is defined by two dates ExecDate and Stopbilldate, if an asofdate is select only data for the suites between execdate and stopbilldate should be returned not all.
--Sample Data
DECLARE @Building TABLE (Bkey int, BID varchar(20))
INSERT INTO @Building VALUES
(1,'BLDG100')
Select * FROM @Building
DECLARE @Tenant TABLE (TKey int, BID VARCHAR(20), SID VARCHAR(2), LID INT, Tenant VARCHAR(20), Execdate DATE, Stopbilldate DATE)
INSERT INTO @Tenant VALUES
(1,'BLDG100', 'A', 1000 , 'Microsoft' , '1/1/2000' , '11/29/2011' ),
(2,'BLDG100', 'A', 0000 , 'Vacant' , '11/30/2011' , '2/29/2012' ),
(3,'BLDG100', 'A', 100000 , 'Google' , '3/1/2012' , '9999-12-31' ),
(4,'BLDG100', 'B', 20000 , 'Yahoo' , '1/1/2011' , '2/25/2012' ),
(5, 'BLDG100', 'B', 0000 , 'Vacant' , '2/26/2012' , '9999-12-31' )
Select * FROm @Tenant
DECLARE @Fact TABLE (Bkey int, Tkey int, Measure Money, Execdate DATE, Stopbilldate DATE)
INSERT INTO @Fact VALUES
(1, 1, 1000 , '1/1/2000' , '11/29/2011' ),
(1, 2, 0 , '11/30/2011' , '2/29/2012' ),
(1, 3, 100000 , '3/1/2012' , '9999-12-31' ),
(1, 4, 20000 ,'1/1/2011' , '2/25/2012' ),
(1, 5, 20000 ,'2/26/2012' , '9999-12-31' )
Select * FROM @Fact
Please let me know Thanks.
Tinku