Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 Datecustomer idstatusReferenceresult I need
01/02/20221Progressed2  
04/02/20221Active3 2
03/02/20222progressed2  
06/02/20223Active2  
05/02/20224Progressed1  
09/02/20224Active2 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

  • 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] )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you, that appears to be working