Forum Discussion

lizzy's avatar
lizzy
Helper I
6 years ago
Solved

Most recent previous date

HI I have a table that looks something like this

Person IDDate
A12/31/2019
A12/1/2019
A10/2/2019
A6/1/2019
B12/10/2019
B10/1/2019
C6/12/2019
C3/1/2019
C2/19/2019

 

For each row, I want to calculate what the previous date was, for that person.

For example:

Person IDDatePrevious
A12/31/201912/1/2019
A12/1/201910/2/2019
A10/2/20196/1/2019
A6/1/2019 
B12/10/201910/1/2019
B10/1/2019 
C6/12/20193/1/2019
C3/1/20192/19/2019
C2/19/2019 

How can I do this?

  • Anonymous's avatar
    Anonymous
    6 years ago
    Previous date =
    var date_ = 'Table'[Date]
    var ID_ = 'Table'[Person ID]
    return
    CALCULATE(MAX('Table'[Date]);FILTER(ALL ('Table') ; 'Table'[Person ID] = ID_ && 'Table'[Date] < date_))

3 Replies