Divide Variable
Divide Variable node is designed to perform division operations on a specified variable and store the result back in the same variable. This node is useful for scaling down values or performing fractional calculations within your workflow.
Properties Panel
Field
Description
Required
Variable Name
The name of the variable whose value will be divided.
true
Value
The value by which the variable will be divided.
true
Usage
Specify the name of the variable whose value you want to divide.
Enter the divisor (the value by which the variable will be divided).
Behaviour
The node will retrieve the current value of the specified variable.
It will then divide this value by the provided divisor.
The result of the division will be stored back in the same variable, overwriting its previous value.
If the variable doesn't exist, it'll raise an error.
Returns
The node updates the value of the specified variable with the result of the division. You can access this updated value using Magical Autocomplete (e.g., $.variables.<variable_name>
) in any node below this node.
Example
Let's say you want to calculate a 50% discount on a price. You already have a variable price
:
Set Variable name to
$.variables.price
Set Value to
0.5
If it exists and price
was 10
, it will now be 5
.
Best Practices
Ensure that the variable you're dividing contains a numeric value to avoid type conversion errors.
Consider adding a check for division by zero before this node if there's any chance the divisor could be zero.
Ensure that the variable is initialised earlier
Last updated