Forum Discussion
Get previous row value
- 3 years ago
Hi Anon29 ,
I would assume that the date has to be considered in the calculation as well and not just the time. If so, create a datetime column first. If those two columns are in the proper date type, you should be able to add both.
datetime = 'table'[date] + 'table'[time]then this column to acccess the previous record that is preceding the current time and which is equal to the current row customer
Previous Purchase = CALCULATE ( LASTNONBLANK ( 'table'[product], 1 ), FILTER ( FILTER ( 'table', 'table'[customer id] = EARLIER ( 'table'[customer id] ) ), 'table'[datetime] < EARLIER ( 'table'[datetime] ) ) )If you don't need to consider the date, just keep the datetime calculated column and use 'table'[time instead] in the second calc column formula.
Hi Anon29 ,
I would assume that the date has to be considered in the calculation as well and not just the time. If so, create a datetime column first. If those two columns are in the proper date type, you should be able to add both.
datetime =
'table'[date] + 'table'[time]
then this column to acccess the previous record that is preceding the current time and which is equal to the current row customer
Previous Purchase =
CALCULATE (
LASTNONBLANK ( 'table'[product], 1 ),
FILTER (
FILTER ( 'table', 'table'[customer id] = EARLIER ( 'table'[customer id] ) ),
'table'[datetime] < EARLIER ( 'table'[datetime] )
)
)
If you don't need to consider the date, just keep the datetime calculated column and use 'table'[time instead] in the second calc column formula.