Forum Discussion

OracleGuru's avatar
OracleGuru
Frequent Visitor
6 years ago
Solved

Calculated Column = Latest value for each visit id

In the example below, I want to create a calculated column that shows the insurance from the last "Trx Date" for the patient's visit id on all rows for that patient's visit id.

 

 
  • OracleGuru try follow measure

     

    Last Insurance = 
    VAR __lastVisitDate = CALCULATE ( MAX ( 'Table'[Trx Date] ), ALLEXCEPT ( 'Table', 'Table'[Visit Id] ) )
    
    RETURN
    CALCULATE ( MAX ( 'Table'[Insurance] ), ALLEXCEPT ( 'Table', 'Table'[Visit Id] ), 'Table'[Trx Date] = __lastVisitDate )

     

2 Replies

  • OracleGuru try follow measure

     

    Last Insurance = 
    VAR __lastVisitDate = CALCULATE ( MAX ( 'Table'[Trx Date] ), ALLEXCEPT ( 'Table', 'Table'[Visit Id] ) )
    
    RETURN
    CALCULATE ( MAX ( 'Table'[Insurance] ), ALLEXCEPT ( 'Table', 'Table'[Visit Id] ), 'Table'[Trx Date] = __lastVisitDate )