Number Calculator

Realiza operaciones matemáticas simples

Overview

The "Number Calculator" node performs simple mathematical operations on numeric fields within incoming data items. It supports addition, subtraction, multiplication, division, and squaring of numbers. This node is useful when you need to calculate new values based on existing numeric data in your workflow, such as summing two amounts, calculating differences, or generating squares for statistical analysis.

Practical examples:

  • Adding two price fields to get a total cost.
  • Subtracting a discount amount from an original price.
  • Multiplying quantity by unit price to get total sales.
  • Dividing total distance by time to calculate speed.
  • Squaring a number to compute variance components.

Properties

Name Meaning
First Number Field The name of the field containing the first number to be used in the operation.
Second Number Field The name of the field containing the second number (not used for the square operation).
Output Field The name of the field where the result of the operation will be stored.

Output

The node outputs an array of items where each item contains the original JSON data plus a new field (as specified by the "Output Field" property) holding the result of the mathematical operation.

  • The output JSON structure is the same as the input with one additional field containing the computed result.
  • No binary data is produced by this node.

Example output JSON snippet:

{
  "number1": 5,
  "number2": 3,
  "result": 8
}

Dependencies

  • No external services or API keys are required.
  • The node relies solely on the input data provided to it.
  • No special environment variables or n8n configurations are needed.

Troubleshooting

  • Invalid number fields: If the specified input fields do not contain valid numbers, the node throws an error indicating which field is invalid. Ensure that the fields contain numeric values.
  • Division by zero: When performing division, if the second number is zero, the node throws an error to prevent division by zero.
  • Unknown operation: If an unsupported operation is selected, the node throws an error indicating the unknown operation.
  • Missing fields: Make sure the field names specified in the properties exist in the input data; otherwise, the conversion to number will fail.
  • To continue processing other items even if some fail, enable the "Continue On Fail" option in the node settings.

Links and References

Discussion