Forum Discussion

Thomas_MedOne's avatar
Thomas_MedOne
Icon for Helper III rankHelper III
4 years ago
Solved

Active patients when slicing by date

I have been looking online and scouring everything looking for the answer to this and I am coming up short. One looked like it could help but the DAX was not validating on my system properly so I mus...
  • mahoneypat's avatar
    4 years ago

    You likely want a measure pattern similar to this one. This assumes that you have a Date table and there is no relationship to from it to the table with your patient data. If you do have a relationship, you can add REMOVEFILTERS(PatientTable) into the CALCULATE.

     

    Active employees =
    VAR mindate =
    MIN ( Date[Date] )
    VAR maxdate =
    MAX ( Date[Date] )
    RETURN
    CALCULATE (
    COUNT ( Table[Employee] ),
    AND (
    Table[StartDate] <= maxdate,
    OR ( Table[TerminationDate] >= mindate, ISBLANK ( Table[TerminationDate] ) )
    )
    )

     

    Pat

  • vojtechsima's avatar
    vojtechsima
    4 years ago

    For Count refer to this: 

    Active employees = 
    VAR mindate =
    MIN ( DateTable[Date] )
    VAR maxdate =
    MAX ( DateTable[Date])
    RETURN
    CALCULATE (
    COUNT ( Admissions[PatientID] ),
    AND (
    Admissions[AdmitDate] <= maxdate,
    OR ( Admissions[DischargDateFixed] >= mindate, ISBLANK ( Admissions[DischargDateFixed]  ) )
    )
    )

    However, this is the same thing but rewritten which mahoneypat proposed earlier. That works, so kudos to this man.