I have a fact which has patient census data with two role Playing cube dimensions, from Admit and Discharge Date. I have them linked as regular in the dimension usage, my requirement is to know the count of patients for a given date considering both admit and discharge date. I'm trying to get this count right as this is used is calculation in other cubes. Hierarchy of my date dimension is Year-Quarter-Month Number-date, can some one kindly help me out, what am i doing wrong here?
My t-sql which woul would give me the correct data would be someting like
Select Count(Distinct encounterid) from dbo.TableNameWhere (Convert(Varchar, AdmitDateTime, 112) >= '20130101' And Convert(Varchar, AdmitDateTime,112) <= '20130131'
Or
Convert(Varchar, DischargeDateTime, 112) >= '20130101' And Convert(Varchar, DischargeDateTime, 112) <= '20130131')
With Member
Measures.CensusCount As
([Measures].[Fact Patient Census Count],
LinkMember([Admit Time].[Calendar Date].CurrentMember ,[Discharge Time].[Calendar Date]),
Root([Admit Time]))
Select
{[Measures].[CensusCount],[Measures].[Fact Patient Census Count] }On Columns,
NonEmpty ([Admit Time].[Calendar Date].[Month Number Of Year].&[2013]&[1]) On Rows
From
[Cube];