What This Workflow Does
This workflow solves a common challenge in automation: accurately counting the number of items returned by any node in your n8n workflow. Many business processes require knowing exactly how many records, responses, or data points were processed at each step.
The template uses a Set node with the Execute Once option to count items efficiently. This approach is particularly valuable for validating data transfers between systems, generating reports with accurate counts, or triggering conditional actions based on quantity thresholds.
How It Works
1. Node Execution
The workflow begins with any node that returns multiple items - this could be a database query, API call, or file processing operation. The node executes normally, returning its set of items.
2. Counting Setup
A Set node is configured with Execute Once option enabled. This ensures the counting operation runs just once for the entire batch of items, rather than processing each item individually.
3. Expression Configuration
The expression within the Set node calculates the count of items returned by the previous node. This count is then available for use in subsequent workflow steps.
Pro tip: Use this count to trigger notifications when item counts exceed or fall below expected thresholds, helping you monitor workflow health.
Who This Is For
This template is ideal for businesses that need to:
- Validate data transfers between systems
- Generate reports with accurate record counts
- Trigger actions based on quantity thresholds
- Monitor workflow health through volume tracking
- Debug workflows by verifying item counts at each step
What You'll Need
- An n8n instance (self-hosted or cloud)
- A node that returns multiple items to count
- Basic familiarity with n8n workflows
Quick Setup Guide
- Download and import the JSON template into your n8n instance
- Connect your source node that returns items to count
- Configure the Set node's expression if needed
- Add any downstream nodes that will use the count
- Test with sample data to verify counting accuracy
Key Benefits
Improved data validation: Ensure complete data transfers by verifying expected counts match actual counts between systems.
Better reporting: Generate more accurate reports with precise counts of processed items rather than estimates.
Conditional logic: Create smarter workflows that branch based on quantity thresholds or alert when counts are abnormal.
Debugging aid: Quickly identify where items might be lost in complex workflows by counting at each step.