# Variable counter for everytime excel writer writes

**URL:** <https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357>\
**Category:** KNIME Analytics Platform\
**Tags:** flow-variables\
**Created:** [March 27, 2025, 9:30am UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357 "2025-03-27T09:30:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LarryFisherman](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/a9a28c/32.png) [@LarryFisherman](https://forum.knime.com/u/LarryFisherman)\
**Post date:** [March 27, 2025, 9:30am UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/1 "2025-03-27T09:30:02Z")

</div>

Hi,

I am working on a flow, where I use quite a lot of excel writers and I would like to use a variable counter to use for naming. So for example everytime an excel writer writes some data, the counter needs to update so 1,2,3 etc.

I am new to using loops and I can’t seem find the right nodes to use.

Additionally, how do I ensure that the counting sequence is the same across all executions? So an excel file called tax\_1 isn’t suddenly called tax\_3 on the next execution.

---

<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:** [March 27, 2025, 2:20pm UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/2 "2025-03-27T14:20:00Z")

</div>

Without knowing the structure of your workflow, its difficult to try to provide a solution. Do you have multiple Excel Writers in your workflow each of which you want to increment for each execution?

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 27, 2025, 4:45pm UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/3 "2025-03-27T16:45:33Z")

</div>

@LarryFisherman you could take a look at this article trying to give some insights and examples about loops.

> **[KNIME, Paths and Loops — Automate Everything](https://medium.com/low-code-for-advanced-data-science/knime-paths-and-loops-automate-everything-213455788685)**
>
> The (few) nodes that will set you on the right path…

> [@LarryFisherman](#):
>
> Additionally, how do I ensure that the counting sequence is the same across all executions? So an excel file called tax\_1 isn’t suddenly called tax\_3 on the next execution.

You can use Flow Variables to make sure the execution within a loop is in the right order.

---

<div class="post-metadata">

**Author:** ![LarryFisherman](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/a9a28c/32.png) [@LarryFisherman](https://forum.knime.com/u/LarryFisherman)\
**Post date:** [March 28, 2025, 8:27am UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/4 "2025-03-28T08:27:17Z")

</div>

Hi rfeigel

Thanks for taking the time to reply. I have made a small flow to illustrate how the structure is. I have also found a solution to both the counting variable and execution order, but I don’t think this is a very elegant way of doing it.

Additionally, I would like to have the number as a part of a larger “naming string” for the sheet name, instead of having just the number as the sheet name. For example tax\_subgroup\_1, tax\_subgroup\_2.

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

---

<div class="post-metadata">

**Author:** ![LarryFisherman](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/a9a28c/32.png) [@LarryFisherman](https://forum.knime.com/u/LarryFisherman)\
**Post date:** [March 28, 2025, 10:13am UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/5 "2025-03-28T10:13:54Z")

</div>

Thanks, much appreciated!

---

<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:** [March 28, 2025, 1:55pm UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/6 "2025-03-28T13:55:48Z")

</div>

Do you want a single workbook with multiple named sheets or multiple workbooks? This is a critical issue for developing a workflow. Could you share your workflow?

---

<div class="post-metadata">

**Author:** ![alpayzeybek](https://forum-cdn.knime.com/user_avatar/forum.knime.com/alpayzeybek/32/78562_2.png) [@alpayzeybek](https://forum.knime.com/u/alpayzeybek)\
**Post date:** [March 28, 2025, 9:07pm UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/7 "2025-03-28T21:07:28Z")

</div>

Hi Larry,

I’ve uploaded a sample workflow addressing your question.

It’s built around an input table that determines:

- How many files will be created
- The target output folder
- File base name

I used a **recursive loop** to generate the file names, followed by a **Table Row to Variable** and **Case Switch** structure to handle the rest of the logic.

And voilà!

You’ll find the screenshots and the KNIME flow attached. Hope it helps. Please feel free to ask your questions.

Best regards,

**Alpay**

 ![Ekran görüntüsü 2025-03-28 235813](https://forum-cdn.knime.com/uploads/default/original/3X/4/f/4f68ac5debf4093769ca74531cbff6eba16a2fcb.png)

 ![Ekran görüntüsü 2025-03-28 235827](https://forum-cdn.knime.com/uploads/default/original/3X/a/0/a0b84d1ce08c8610ab543f5572acec2539a37090.png)

 ![Ekran görüntüsü 2025-03-28 235853](https://forum-cdn.knime.com/uploads/default/original/3X/7/d/7daf40a61c89fd5be0798a9d36b4bb03f667b91c.png)

 ![Ekran görüntüsü 2025-03-28 235932](https://forum-cdn.knime.com/uploads/default/original/3X/0/c/0c865ab321033ad98df0a5455e533387f6f2171f.png)

[Variable counter for everytime excel writer writes.knwf](https://forum.knime.com/uploads/short-url/uNoZnbE5USf87Nf2KURTeP3UMxY.knwf) (45.5 KB)

---

<div class="post-metadata">

**Author:** ![LarryFisherman](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/a9a28c/32.png) [@LarryFisherman](https://forum.knime.com/u/LarryFisherman)\
**Post date:** [March 31, 2025, 7:16am UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/8 "2025-03-31T07:16:14Z")

</div>

Hi Alpay,

This very much seems like what I was looking for, thanks! I can’t for some reason open the attached knwf file, can it be shared in a different way?

---

<div class="post-metadata">

**Author:** ![alpayzeybek](https://forum-cdn.knime.com/user_avatar/forum.knime.com/alpayzeybek/32/78562_2.png) [@alpayzeybek](https://forum.knime.com/u/alpayzeybek)\
**Post date:** [March 31, 2025, 8:01am UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/9 "2025-03-31T08:01:25Z")

</div>

Hi Larry, thank you. I apologize for the inconvenience caused by the malfunctioning link.

Please check this link:

[VariableFlow.knwf](https://forum.knime.com/uploads/short-url/kTP5k3kdk5qi84B03YBUXccFWE0.knwf) (43.8 KB)

Best,

Alpay

---

<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:** [May 7, 2025, 8:57am UTC](https://forum.knime.com/t/variable-counter-for-everytime-excel-writer-writes/87357/10 "2025-05-07T08:57:13Z")

</div>

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