title: Add calculated custom column using entire table for calculation power query or dax
body: <p>I have this table in Power BI with events concerning some objects</p>
  
  <hr>
  
  <h2>|new_state |object_id     | created_at           |</h2>
  
  <h2>|new       |1             |11/4/2015 1:50:48 PM  |</h2>
  
  <h2>|in_use    |3             |11/4/2015 2:31:10 PM  |</h2>
  
  <h2>|in_use    |1             |11/4/2015 2:31:22 PM  |</h2>
  
  <h2>|deleted    |2             |11/4/2015 3:14:10 PM  |</h2>
  
  <p>.....   </p>
  
  <p>I am trying to add a calculated column either in DAX or power query so that for each row I would have the previous_state of that object. From a logical point of view it's not difficult: you group by id and for each row in that group you look for the closest previous time and get the "new_state" which would represent the previous state for that row.
  I have tried doing this by creating a function in power query and use it in a custom column but I am getting a "cyclic reference detected" error and cannot do it. Any ideas on solutions? </p>