Forum Discussion

DanielB_NL's avatar
DanielB_NL
Helper I
2 years ago

Adding conditional column with either value from other column OR the value from the row above

Hi All, 

I'm still trying to find my way in PowerBi and to solve some interesting questions, which I have.

 

I have this query that generates the upper table: it put some expected mutations for a specific item no. in a time line and checks whether theoretticaly the stock is not sufficient. So this is nice, but now I want to see what my options are if the stock is not sufficient for the expected mutation:

  • If there is an expected Purchase Order due to arrive just before the mutation, I would like to know when and what amount: if I know which Purchase Order I can call the supplier to try to increase the ordered amount
  • If there is an expected Purchase Order due to arrive just after the mutation, I would like to know when and what amount: if I know which Purchase Order I can call the supplier to try to get the items easlier.

Can someone tell me how to add such a conditional column? So for 'Previous_purchase' I would like to check if the column 'type' has the value 'Purchase' on the previous row and if so, I woulde like to get the Reference and put it in the column 'Previous_purchase'. If the column 'type' has not the value 'Purchase' on the previous row, then I would like in 'Previous_purchase' to repeat the value of the previous row.

 

If I'm able to make such an overview, I only have to look at the row with the negative stock after mutation, and I can see directly which Purchase Order(s) are involved.

 

I hope you can help me out, thanks in advance!

 

11 Replies