# Using previous row values to create values for a new column

**URL:** <https://discourse.julialang.org/t/using-previous-row-values-to-create-values-for-a-new-column/57481>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [March 18, 2021, 3:25pm UTC](https://discourse.julialang.org/t/using-previous-row-values-to-create-values-for-a-new-column/57481 "2021-03-18T15:25:49Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [March 18, 2021, 4:31pm UTC](https://discourse.julialang.org/t/using-previous-row-values-to-create-values-for-a-new-column/57481/4 "2021-03-18T16:31:22Z")

</div>

While direct method is no doubt efficient, if you are coming from an SQL world, you probably want to use something like ShiftedArrays.jl which has `lag` and `lead` functions: [ANN: ShiftedArrays and support for ShiftedArrays in GroupedErrors](https://discourse.julialang.org/t/ann-shiftedarrays-and-support-for-shiftedarrays-in-groupederrors/9162)

---

_[View the full topic](https://discourse.julialang.org/t/using-previous-row-values-to-create-values-for-a-new-column/57481)._
