Forum Discussion
return previous value in a calculated column
Hi
I am new to power bi and Dax. i am trying to return a previous value in a table. my data is similar to below:
| Created Date | customer id | status | Reference | result I need | |
| 01/02/2022 | 1 | Progressed | 2 | ||
| 04/02/2022 | 1 | Active | 3 | 2 | |
| 03/02/2022 | 2 | progressed | 2 | ||
| 06/02/2022 | 3 | Active | 2 | ||
| 05/02/2022 | 4 | Progressed | 1 | ||
| 09/02/2022 | 4 | Active | 2 | 1 |
if a customer has both progressed and active in the status column i need to return the value for the progressed next to the active column so i can compare if it has increased/decreased.
Anonymous ,
New column =
var _max = maxx(filter(Table, [Customer Id] = earlier( [Customer Id] ) && [Created Date] < earlier([Created Date]) ),[Created Date] )
return
maxx(filter(Table, [Customer Id] = earlier( [Customer Id] ) && [Created Date] = _max ),[Reference] )
2 Replies
- amitchandak
Super User
Anonymous ,
New column =
var _max = maxx(filter(Table, [Customer Id] = earlier( [Customer Id] ) && [Created Date] < earlier([Created Date]) ),[Created Date] )
return
maxx(filter(Table, [Customer Id] = earlier( [Customer Id] ) && [Created Date] = _max ),[Reference] )
- AnonymousNot applicable
Thank you, that appears to be working