Forum Discussion
Anonymous
3 years agoNot applicable
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
- AilleryOMemorable 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 indexIt should give you this :Let us know- AnonymousNot applicable
Can we derrive this in Power Query?
- AilleryOMemorable Member
Hi,
Certainly yes, maybe using LastN function or else, but I must confess I do not have a solution ready made for you.
This might guide you :
https://radacad.com/grouping-in-power-query-getting-the-last-item-in-each-group
Let us know if you found your solution
- JadhavVarsha_13Helper V
Hi,
You can try Lookup
LookupValue( <result column>, <search column>, <search value>, [<search columnname>, <search value> [, ...] ],[,<alternate result>])