3 min read

Dividetwonumbers

Purpose

This node is designed to perform division between two numeric values. It takes in two numbers as inputs, checks for validity, and safely computes their quotient. The results can then be used in further computations or data analytics processes within the Vantage platform.

Settings

Input Settings

  1. Setting Name: input1

    • Input Type: Numeric (can be a string or number)
    • Description: This is the first value to be divided. If not provided in the inputs, it defaults to the value specified in the configuration or falls back to 1. Changing this setting alters the value that will be divided by the second input.
    • Default Value: 1
  2. Setting Name: input2

    • Input Type: Numeric (can be a string or number)
    • Description: This is the second value used as the divisor. If not provided in the inputs, it defaults to the value specified in the configuration or falls back to 1. Adjusting this value will change the divisor, affecting the outcome of the division. Furthermore, it is critical to ensure this value is not 0, as division by zero is mathematically undefined.
    • Default Value: 1

Error Handling

The function includes basic validations:

How It Works

Expected Data

The function expects the following data structure for inputs:

json
{
  "inputs": {
    "input1": <number or string>,
    "input2": <number or string>
  },
  "config": {
    "input1": <number or string>,
    "input2": <number or string>
  }
}

Use Cases & Examples

Use Cases

  1. Financial Analysis: A company can use this logic to calculate profit margins by dividing profit by total revenue to assess efficiency.
  2. Data Normalization: In a dataset, certain values may need to be normalized against a base value, which can be handled through division.
  3. Dynamic Reporting: A reporting tool can leverage this logic to create real-time analytics dashboards that display ratios, such as conversion rates (sales divided by leads).

Example Configuration

Use Case: Calculate profit margin from sales data.

Configuration Data:

json
{
  "inputs": {
    "input1": "15000",    // Profit
    "input2": "50000"     // Total Revenue
  },
  "config": {}
}

Expected Output: The function would process this input and return:

json
{
  "output1": 0.3   // The profit margin rate of 30%
}

In this example, the profit of $15,000 is divided by total revenue of $50,000 to yield a profit margin of 30%. This insight can be crucial for stakeholders analyzing business performance.