Usage Billing icon

Usage Billing

Process pricing and usage data to generate billing records

Overview

The node provides a "Usage Summary" operation that aggregates numerical data fields from input records, optionally grouping the results by specified fields. It is useful for summarizing usage or billing data where totals of certain fields (e.g., costs, quantities, amounts) need to be calculated across multiple records. For example, it can total sales amounts grouped by product and region, or aggregate resource consumption metrics grouped by customer or project.

Typical scenarios include:

  • Generating summarized billing reports from detailed usage logs.
  • Calculating total quantities or costs per category or time period.
  • Producing aggregated metrics for dashboards or further processing.

Properties

Name Meaning
Fields to Total Comma-separated list of field names whose values will be summed. For each field, a total_[field name] will appear in the output summary. Example: calc_cost_amount,calc_sell_amount,quantity. This property is required.
Group By Fields Optional comma-separated list of field names to group the summary by. Records with the same values in these fields are aggregated together. Example: product_id,region. If empty, all records are aggregated into a single summary.
Include Source Data Boolean flag indicating whether to include the original input records alongside the summary output. If true, the source data is included in the output for reference or further use.

Output

The output JSON contains an array of summary objects. Each object corresponds to one group defined by the "Group By Fields" (or a single summary if no grouping is specified). Each summary object includes:

  • The group-by field values (if any).
  • Total fields named as total_[field name] representing the sum of each specified field across the grouped records.
  • Optionally, if "Include Source Data" is enabled, the original input records related to that group are included.

No binary data output is indicated by the code.

Dependencies

  • No external services or API keys are required specifically for this operation.
  • The node depends on internal helper functions imported from a local processing module to perform the aggregation logic.
  • No special environment variables or n8n credentials are needed for the "Usage Summary" operation.

Troubleshooting

  • Empty or incorrect field names: If the "Fields to Total" or "Group By Fields" contain typos or fields not present in the input data, the totals may be zero or missing. Verify field names match exactly those in the input.
  • Non-numeric fields in totals: Summation expects numeric values. Non-numeric or missing values in the fields to total may cause errors or incorrect results.
  • Large datasets: Processing very large input arrays might impact performance or memory usage.
  • Include Source Data flag: Enabling this increases output size; disable if not needed to optimize performance.

Common error messages would likely relate to invalid parameters or unexpected data types, which can be resolved by checking input data structure and property configurations.

Links and References

Discussion