๐Ÿ‡ฌ๐Ÿ‡ง EN
๐Ÿ‡ฎ๐Ÿ‡น IT

๐Ÿ”ข 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:

  1. Before a loop, use Set Variable to initialise a numeric variable to 0.
  2. Inside the loop body, use Counter (possibly inside a Logic Gate true branch) to increment whenever a condition is met.
  3. 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".
// Access the Counter's output in the same or later steps (replace "counter_step" with your step key) {{ counter_step.output.value }} {{ counter_step.output.previous_value }} // Or access the updated variable directly by name {{ email_count }}

Example Usage

Count successfully sent emails inside a loop

  1. Add a Set Variable node before the loop:
    Name: sent_count Type: number Value: 0
  2. Add a Loop node iterating over {{ fetch.output.recipients }}.
  3. Inside the loop, add a Send Email node. It returns a success boolean in its output.
  4. After the Send Email node, add a Logic Gate. Check that {{ send_email.output.success }} equals true.
  5. On the true branch, add a Counter node:
    Variable: sent_count Operation: increment Amount: 1
  6. 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

// Initialise before loop Name: total_quantity Type: number Value: 0 // Counter inside loop โ€” amount comes from the current item Variable: total_quantity Operation: increment Amount: {{ loop_step.current_item.quantity }}

Tips & Notes

Related Nodes