Forum Discussion

yve214's avatar
yve214
Helper III
4 years ago
Solved

Urgent Help with Creating a Flag column

Problem: Please, I am trying to check if my recent admission location is the same as my recent discharge location and create a flag to help me with my other measures. How to approach this.   check...
  • tamerj1's avatar
    4 years ago

    Hi yve214 

    please try

    Flag =
    VAR CurrentIDTable =
        CALCULATETABLE ( Table1, ALLEXCEPT ( Table1, Table1[patient_Id] ) )
    VAR LastAdmissionLocation =
        MAXX ( TOPN ( 1, CurrentIDTable, Table1[admission_date] ), Table1[Location] )
    VAR LastDischargeLocation =
        MAXX ( TOPN ( 1, CurrentIDTable, Table1[discharge_date] ), Table1[Location] )
    RETURN
        IF ( LastAdmissionLocation = LastDischargeLocation, 1 )