๐ข Counter
Increments or decrements a numeric workflow variable by a specified amount. Designed for
use inside loops and conditional branches to track progress, counts, and running totals.
Category: Data Manipulation ยท Type identifier: counter
Overview
The Counter node is a specialised companion to Set Variable.
Where Set Variable creates and overwrites variables, Counter does one focused thing:
it takes an existing numeric variable and adds or subtracts a value from it. This is more
expressive and less error-prone than using Set Variable to manually reconstruct a new value
from the current one.
The most common pattern is:
- Before a loop, use Set Variable to initialise a numeric variable to
0.
- Inside the loop body, use Counter (possibly inside a Logic Gate true branch) to
increment whenever a condition is met.
- After the loop, read the variable's final value to report a total count.
Counter can also be used outside loops โ for example, to track how many retries have
been attempted, or to decrement a remaining-quota variable.
The variable must already exist. Counter modifies an existing variable. If
the named variable does not exist when Counter runs, the step will fail. Always precede it
with a
Set Variable node that initialises the variable.
Configuration
| Field |
Status |
Description |
| Variable |
Required |
The name of the numeric variable to modify. Enter the variable name only โ no {{ }} braces. Example: email_count. |
| Operation |
Required |
increment โ add the Amount to the current value; decrement โ subtract the Amount from the current value. |
| Amount |
Optional |
How much to add or subtract. Defaults to 1 if not specified. Accepts a static number or a {{ variable }} reference for dynamic amounts. For example, {{ loop_step.current_item.quantity }} to sum quantities rather than just count items. |
Output Data
| Variable |
Type |
Description |
value |
number |
The new value of the variable after the operation. |
previous_value |
number |
The value of the variable before the operation. Useful for logging or comparing before/after. |
variable_name |
string |
The name of the variable that was modified. |
operation |
string |
Either "increment" or "decrement". |
{{ counter_step.output.value }}
{{ counter_step.output.previous_value }}
{{ email_count }}
Example Usage
Count successfully sent emails inside a loop
-
Add a Set Variable node before the loop:
Name: sent_count
Type: number
Value: 0
-
Add a Loop node iterating over {{ fetch.output.recipients }}.
-
Inside the loop, add a Send Email node. It returns a
success boolean in its output.
-
After the Send Email node, add a Logic Gate. Check that
{{ send_email.output.success }} equals true.
-
On the true branch, add a Counter node:
Variable: sent_count
Operation: increment
Amount: 1
-
After the loop ends, reference the final total:
{{ sent_count }} emails were sent successfully out of {{ loop_step.output.count }} attempted.
Sum order quantities rather than counting items
Name: total_quantity
Type: number
Value: 0
Variable: total_quantity
Operation: increment
Amount: {{ loop_step.current_item.quantity }}
Tips & Notes
-
Always initialise first. The Counter will fail if the variable does not
already exist. Place a Set Variable node before any loop or branch that uses Counter.
-
You can use Counter outside loops. It works anywhere in a workflow โ for
example, to count how many branches in a Switch have been reached, by placing a Counter
at the start of each branch.
-
Decrement for quota tracking. Initialise a variable to the total allowed
(e.g.
5) and decrement by 1 on each action. Then use a Logic Gate to check
{{ remaining_quota }} is greater than 0 before continuing.
-
Fractional amounts. While Counter is most commonly used with integers,
it also handles decimal amounts โ useful for summing prices or weights.
Related Nodes
- Set Variable โ initialise the variable before using Counter.
- Loop โ the most common context for Counter nodes.
- Logic Gate โ check the counter's value to decide whether to continue.