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 compute new values based on existing numeric data in your workflow, such as calculating differences, totals, or derived metrics.

For example, you can use it to subtract one field value from another to find the difference between two measurements, multiply quantities for total cost calculations, or square a number for statistical computations.

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.
  • Operation (not listed in the user properties but part of the node): Options include Add, Subtract, Multiply, Divide, and Square.

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.

Example output JSON structure for one item:

{
  "json": {
    "number1": 10,
    "number2": 4,
    "result": 6
  }
}

Here, result holds the subtraction of number2 from number1.

The node does not output binary data.

Dependencies

  • No external services or API keys are required.
  • The node relies solely on input data fields and internal JavaScript operations.

Troubleshooting

  • Invalid Number Fields: If the specified "First Number Field" or "Second Number Field" does not contain a valid number, the node throws an error indicating which field is invalid.
  • Division by Zero: Attempting to divide by zero results in an error with a clear message.
  • Unknown Operation: If an unsupported operation is selected, the node throws an error specifying the unknown operation.
  • To handle errors gracefully, enable the "Continue On Fail" option in the node settings to allow processing of subsequent items even if some fail.

Links and References

Discussion