Calculate Mesaure across 2 Dimensions

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.TableName 
Where (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];

February 6th, 2015 1:51pm

There's probably a way to do this with MDX, but I don't know it.  I typically rely on structuring my models so that such questions just fall out as simple aggregates.  Here, for instance, if you had a fact at the grain of (Patient,Day) for each day the patient was there you could just use a Count.

You can generate this fact by joining your encounter table with the date table to generate a row for each day of the stay.

David

Free Windows Admin Tool Kit Click here and download it now
February 6th, 2015 1:57pm

Thank you for your reply, my problem is that I cannot change the structure of Fact table no more, I'l have try and achieve this with an MDX I have this being referenced by other cubes. Any insight of the exact MDX to get this would be very helpful. 
February 6th, 2015 2:09pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics