Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Return Previous Date

Hello, I know there is documentation out there, but maybe there’s a better answer. I want to return the previous date of and ID.
I have a PatientID, Admit Date.
I want to create a new column called Previous Admit Date which will return the Previous Admit Date for the patient ID and if no previous just leave blank.

4 Replies

  • AilleryO's avatar
    AilleryO
    Memorable Member

    Hi,

     

    You can add an index column using Power Query, to have a unique ID for your lines.

    And then you can try :

    Last Admi Date = 
     VAR CurrPatient = SELECTEDVALUE( TabPatient[Patient ID] )//Store ID you work with
     VAR CurrIndex = CALCULATE( MAX( TabPatient[Index] ) , TabPatient[Patient ID] = CurrPatient )//Store the last index for last date of patient
     RETURN
     CALCULATE ( MIN ( TabPatient[Admi Date] ) , //Check the MIN date
     CurrPatient = TabPatient[Patient ID] ,  //for that patient
     CurrIndex<>TabPatient[Index]  ) //not being the date of this line index
     It should give you this :
    Let us know
  • Hi,

     

    You can try Lookup 

    LookupValue( <result column>, <search column>, <search value>, [<search columnname>, <search value> [, ...] ],[,<alternate result>])