# How to compare a column's value from one row to the next one?

**URL:** <https://forum.knime.com/t/how-to-compare-a-columns-value-from-one-row-to-the-next-one/8073>\
**Category:** KNIME Analytics Platform\
**Created:** [June 4, 2015, 9:15am UTC](https://forum.knime.com/t/how-to-compare-a-columns-value-from-one-row-to-the-next-one/8073 "2015-06-04T09:15:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ulja](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/e9c0ed/32.png) [@Ulja](https://forum.knime.com/u/Ulja)\
**Post date:** [June 4, 2015, 9:15am UTC](https://forum.knime.com/t/how-to-compare-a-columns-value-from-one-row-to-the-next-one/8073/1 "2015-06-04T09:15:13Z")

</div>

Hello Knimlings,

I want to compute if a value is increasing or decreasing from one row to the next row.

E.g.:  
The Input

| Row0 | 3 |
| Row1 | 6 |
| Row2 | 4 |

should result in

| Row0 | 3 | - |
| Row1 | 6 | 1 |
| Row2 | 4 | 0 |

where 1 is incresing value and 0 is decreasing value.

Is this possible using Data Manipulation nodes?

&nbsp;

Best regards

Ulja

---

<div class="post-metadata">

**Author:** ![aborg](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/c89c15/32.png) [@aborg](https://forum.knime.com/u/aborg)\
**Post date:** [June 4, 2015, 12:25pm UTC](https://forum.knime.com/t/how-to-compare-a-columns-value-from-one-row-to-the-next-one/8073/2 "2015-06-04T12:25:04Z")

</div>

You can create a shifted column with the [Lag Column](https://forum.knime.com/sites/default/files/inline-images/_manipulation_column_column_transform_Lag_Column.html) node and based on that info, you can compute the desired output using the Math Formula or a Java Snippet node for example.  
 &nbsp;

---

<div class="post-metadata">

**Author:** ![Ulja](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/e9c0ed/32.png) [@Ulja](https://forum.knime.com/u/Ulja)\
**Post date:** [June 4, 2015, 1:28pm UTC](https://forum.knime.com/t/how-to-compare-a-columns-value-from-one-row-to-the-next-one/8073/3 "2015-06-04T13:28:15Z")

</div>

Thank you aborg. Lag Column node does the job.

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:25pm UTC](https://forum.knime.com/t/how-to-compare-a-columns-value-from-one-row-to-the-next-one/8073/4 "2023-06-23T20:25:40Z")

</div>


