# Difference between ROWS based on conditions

**URL:** <https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269>\
**Category:** KNIME Extensions\
**Tags:** scripting\
**Created:** [February 10, 2025, 10:23pm UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269 "2025-02-10T22:23:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barajas](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/b/a5b964/32.png) [@Barajas](https://forum.knime.com/u/Barajas)\
**Post date:** [February 10, 2025, 10:23pm UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/1 "2025-02-10T22:23:42Z")

</div>

KNIMERS,  
I am struggling to find a way of finding the difference on the column  
‘Sum(Qty)’

for those amouts that belong to the same:  
‘Customer\_Name’,  
‘Item’  
‘DD\_YrMnth’

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/0/e/0e36fe1a34d549a6b649b0d6857fc4cf0b917fde.png)

I have manually created column ‘Delta Column’ that provides the results that I need to program in KNIME.  
Column G5, no operation needs to be done since its the first iteration of ‘QTY’ for that same ‘Customer\_name’ & ‘Item’ & ‘DD\_YrMnth’  
Column G6 shows the result of D6-D5 which is zero  
Column G7 shows the result of D7-D6  
Finally, the process repeats itself for any “group” of ‘Customer\_name’ & ‘Item’ & ‘DD\_YrMnth’  
Thank you in advanced for any suggestion on this.

---

<div class="post-metadata">

**Author:** ![rfeigel](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@rfeigel](https://forum.knime.com/u/rfeigel)\
**Post date:** [February 11, 2025, 12:32am UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/2 "2025-02-11T00:32:54Z")

</div>

Can you share some sample data? Is there a reason you’re using an unusual date format?

---

<div class="post-metadata">

**Author:** ![Barajas](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/b/a5b964/32.png) [@Barajas](https://forum.knime.com/u/Barajas)\
**Post date:** [February 11, 2025, 1:43am UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/3 "2025-02-11T01:43:33Z")

</div>

@rfeigel thanks for helping, I’m attaching a sample of my data. the screenshot above I created specifically to highlight my description,  
but this is how it looks on my table

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/c/5/c5255af05175e2bf7398175606c8dc8ed0a7ee07.png)

[KNIME SHARED SAMPLE.xlsx](https://forum.knime.com/uploads/short-url/a0tKFLtcimacqViMQ6pmBsBjtnt.xlsx) (9.6 KB)

---

<div class="post-metadata">

**Author:** ![rfeigel](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@rfeigel](https://forum.knime.com/u/rfeigel)\
**Post date:** [February 11, 2025, 2:23am UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/4 "2025-02-11T02:23:10Z")

</div>

What version of Knime are you using? The data you uploaded isn’t the same as your screenshot. The upload has essentially no differences for Sum(Qty) row to row.

---

<div class="post-metadata">

**Author:** ![Barajas](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/b/a5b964/32.png) [@Barajas](https://forum.knime.com/u/Barajas)\
**Post date:** [February 11, 2025, 4:45pm UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/5 "2025-02-11T16:45:39Z")

</div>

> [@rfeigel](#):
>
> he upload has essentially no differences for Sum(Qty) row to row.

knime version is 5.4.1.

I am attaching a knime workflow with a wide data set, in the screenshot below im selecting rows of that table that, for the same date in DD\_YrMnth (202409) have different amounts (150, 100 & 100), the expected result would be the difference between the first two amounts, and a second result with the

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/1/8/1876b43c361ef249c14b1e33dc9233bb66c0e09b.png)  
[Sales Variance Table.knwf](https://forum.knime.com/uploads/short-url/v5nd74hY6MglTIAqpF3afTZAxhR.knwf) (252.5 KB)

---

<div class="post-metadata">

**Author:** ![rfeigel](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@rfeigel](https://forum.knime.com/u/rfeigel)\
**Post date:** [February 12, 2025, 1:27am UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/6 "2025-02-12T01:27:22Z")

</div>

I’m not 100% sure I understand what you’re after. Try this:

> **[Difference Between Rows Based on Conditions rev 1 – rfeigel](https://hub.knime.com/rfeigel/spaces/Public/Difference%20Between%20Rows%20Based%20on%20Conditions%20rev%201~GF9YjKaa8TXbcthJ/current-state)**
>
> Solutions for data science: find workflows, nodes and components, and collaborate in spaces.

---

<div class="post-metadata">

**Author:** ![Barajas](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/b/a5b964/32.png) [@Barajas](https://forum.knime.com/u/Barajas)\
**Post date:** [February 12, 2025, 4:57pm UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/7 "2025-02-12T16:57:11Z")

</div>

This is exactly what I needed. I am so grateful.

---

<div class="post-metadata">

**Author:** ![rfeigel](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@rfeigel](https://forum.knime.com/u/rfeigel)\
**Post date:** [February 12, 2025, 5:02pm UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/8 "2025-02-12T17:02:06Z")

</div>

Could you please mark solved.

---

<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:** [February 19, 2025, 5:02pm UTC](https://forum.knime.com/t/difference-between-rows-based-on-conditions/86269/9 "2025-02-19T17:02:28Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
