Forum Discussion

Krushnab85's avatar
Krushnab85
Helper I
1 year ago
Solved

Need Help with Dax

Hi, I have calendar Dimension Table and i have patient fact table having cardinality one to many from calendar to Patient Table (Cal_Date >>Enrollment Date).  Now i want to calculate the counts of pa...
  • FarhanJeelani's avatar
    FarhanJeelani
    1 year ago

    Hi Krushnab85 ,

    To ensure that the calendar filters the correct stage date dynamically, modify your measures using ALL to ignore the active relationship and then apply the correct date filter using TREATAS.


    Enrollments Count (Respects Active Relationship)

    No_of_Enrollments = COUNT(Patient_Fact[Patient ID])

    (This works as expected since Cal_Date >> Enrollment Date is active)

     

    Admissions Count

    No_of_Admissions =
    CALCULATE(
    COUNT(Patient_Fact[Patient ID]),
    ALL(Patient_Fact), -- Removes any filter from Enrollment Date
    TREATAS( VALUES(Calendar[Cal_Date]), Patient_Fact[Admission Date])
    )


    Billings Count

    No_of_Billings =
    CALCULATE(
    COUNT(Patient_Fact[Patient ID]),
    ALL(Patient_Fact),
    TREATAS( VALUES(Calendar[Cal_Date]), Patient_Fact[Billing Date])
    )


    Infusions Count

    No_of_Infusions =
    CALCULATE(
    COUNT(Patient_Fact[Patient ID]),
    ALL(Patient_Fact),
    TREATAS( VALUES(Calendar[Cal_Date]), Patient_Fact[Infusion Date])
    )

     

    Please mark this post as solution if it helps you. Appreciate Kudos.