Item Counter and Data Tally Utility - n8n Workflow

Learn how to accurately count the total number of items returned by a previous n8n node using array expressions. This fundamental n8n workflow is essential for data auditing.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users new to n8n who need to master data manipulation techniques.
Automation developers requiring precise item counts for logging or QA steps.
Anyone auditing results from data extraction, API calls, or database queries within an n8n workflow.
Teams looking for robust, reusable n8n templates for core logic.

Overview

This n8n workflow demonstrates a critical skill for any automation specialist: determining the exact number of items passed between nodes. When integrating with APIs or databases, knowing the item count is vital for data integrity checks and subsequent conditional routing. This simple but powerful n8n template uses the Set n8n node combined with a specific expression to count the total records returned by a previous n8n node, effectively transforming a list into a single metric. This approach ensures accurate flow control and auditing within your larger n8n workflows.

How it Works

This automation is initiated manually for demonstration purposes, making it easy to test and adapt.


  1. Trigger: The process begins with the 'When clicking "Execute Workflow"' n8n trigger, allowing for immediate testing.

  2. Data Fetch: The 'Customer Datastore (n8n training)' n8n node simulates fetching a list of records (e.g., pulling all people from a database).

  3. Counting: The data array output from the previous step is passed to the 'Set' n8n node. This n8n node uses the expression {{ $input.all().length }} to count every incoming item.

  4. Output: The result is a single output item containing the calculated itemCount, ready to be used in subsequent steps like logging or notifications within your n8n workflow. This is a highly reusable n8n template for data analysis.

Installation Guide

To deploy this n8n workflow:


  1. Copy JSON: Copy the provided n8n workflow JSON.

  2. Import: In your n8n instance, click the 'New' button, select 'Import from JSON', and paste the code.

  3. Execution: Since this specific n8n workflow uses a specialized 'n8n training' node for data retrieval and a manual n8n trigger, no credentials are required. Simply click 'Execute Workflow' to see the item counting logic in action.

  4. Adaptation: To use this logic in a live n8n workflow, replace the 'Customer Datastore (n8n training)' n8n node with your actual data source (e.g., Google Sheets, API, or database) and modify the trigger accordingly.

Node Details

When clicking "Execute Workflow" (Manual Trigger): The starting n8n trigger for this flow. It facilitates manual testing of the n8n workflow logic.
Customer Datastore (n8n training): Serves as a placeholder n8n node. Its function is to simulate fetching multiple records (getAllPeople), providing the array data necessary for the next step's count calculation.


  • Set: This is the core logical n8n node. It is configured to create a new property, itemCount, whose value is determined by the crucial expression ={{ $input.all().length }}. This expression precisely counts the number of input items received from the previous n8n node, effectively proving the power of n8n templates and expressions.

Related n8n Workflows

Free

Nodes: 3 Nodes
Updated: December 26 2025
View all
Created by

Featured*