# \[loop help\] sum numbers till meet target

**URL:** <https://forum.knime.com/t/loop-help-sum-numbers-till-meet-target/78714>\
**Category:** KNIME Analytics Platform\
**Tags:** big-data\
**Created:** [April 23, 2024, 2:33pm UTC](https://forum.knime.com/t/loop-help-sum-numbers-till-meet-target/78714 "2024-04-23T14:33:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zerobserver](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zerobserver](https://forum.knime.com/u/zerobserver)\
**Post date:** [April 23, 2024, 2:33pm UTC](https://forum.knime.com/t/loop-help-sum-numbers-till-meet-target/78714/1 "2024-04-23T14:33:05Z")

</div>

I want to sum the numbers till it meet a target like 500. =\> iteration 1  
then start a new round of calculation till hit target again and till the loop end.  
I tired a stupid way using moving aggregation with “window 2” .Then filter out the result that is off sum up target and aggregate with “window 3” … … …  
Should I use the _Variable Condition Loop_ in this case? I tried but failed… 🥲  
Please help me 🌹 🌻

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/f/8/f830843a1645cbc96bb379c53e649dffd302f179.jpeg)

---

<div class="post-metadata">

**Author:** ![mwiegand](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mwiegand/32/66896_2.png) [@mwiegand](https://forum.knime.com/u/mwiegand)\
**Post date:** [April 26, 2024, 1:03pm UTC](https://forum.knime.com/t/loop-help-sum-numbers-till-meet-target/78714/2 "2024-04-26T13:03:51Z")

</div>

Hi @zerobserver,

I tried creating a possible solution following your definition but am not quite certain about the results. To double verify what should happen can you please check the following if that meets what you have in miind?

1. Check if value of current cell \>= threshold 500
2. If true write result to column “Result”
3. If false / threshold is not met, calculate “temp-result” by sum of current + next cell
4. Check if temp-result \>= threshold 500
5. If true, write result to column “Result”
6. If false / threshold is not met, continue until condition is met / end of column

---

<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:** [July 25, 2024, 1:04pm UTC](https://forum.knime.com/t/loop-help-sum-numbers-till-meet-target/78714/3 "2024-07-25T13:04:48Z")

</div>

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