Artisan SVG > Math Helpers (math-helpers) (calculator-1)
Artisan SVG > Math Helpers (math-helpers) (calculator-1)

Math Helper
2.0

The Math Helper interacts with numbers and list of numbers

Overview
Copy

The Math Helper connector allows you to interact with numbers and list of numbers.

Operations
Copy

Add
Copy

The operation adds two numbers together.

Both numbers' values can be obtained from previous workflow steps using jsonpaths.

Average
Copy

This operation calculates the average of a list of numbers.

The list of numbers can be obtained from previous workflow steps using jsonpaths.

Divide
Copy

To understand how to use the Math Helper connector's divide operation, consider a scenario where you want to allocate a budget between departments.

A simple formula to do so is: Budget / Number of departments.

In this scenario the workflow receives the following information from the Webhook trigger.

1
{
2
"total_budget": 753249,
3
"departments": [
4
{
5
"name": "Marketing",
6
"dept_info": {
7
"info": "Responsible for promoting products and services to target customers."
8
}
9
},
10
{
11
"name": "Operations",
12
"dept_info": {
13
"info": "Responsible for managing day-to-day activities and ensuring efficient business operations."
14
}
15
}
16
],
17
"total_departments": 2
18
}

The First value and the Second value, in this case, total_budget and total_departments, can be obtained from previous workflow steps using jsonpaths.

Multiply
Copy

To understand how to use Math Helper connector's multiply operation consider a scenario where you wish to convert hours to minutes.

A simple formula to do so is: hours × 60 minutes.

In this scenario the workflow receives the hours from the Webhook trigger:

1
{
2
"task": {
3
"name": "Task 1",
4
"duration_hours": 1.5
5
}
6
}

The connector, using the Multiply operation, multiplies the "First value" parameter with the "Second value" parameter (60) to convert hours to minutes.

Parse number
Copy

The operation extracts numerical values from a text string.

The operation is useful when you have a string that contains numeric data but is embedded within other characters or words.

For example, "The price is $50". The operation will extract the numeric value 50 from the string and convert it into a numerical data type for further processing.

Remainder
Copy

The remainder operation, also known as modulo operation or modulus operation, calculates the remainder of a division operation.

Given two numbers, it divides the Value by the Divider, providing the remainder.

For example, if you perform the operation 10 % 3, the remainder is 1, because 10 divided by 3 equals 3 with a remainder of 1.

Round
Copy

The round operation is used to round a number to a specified number of decimal places (Decimal precision) or to the nearest whole number.

For example, if you have the number 3.7 and you round it to the nearest whole number, the result would be 4. If you round it to one decimal place, the result would be 3.7.

Run expression
Copy

The Run expression operation allows you to evaluate an expression.

Let's consider an expression to understand the order in which the expression would be evaluated and the supported operators:

10**2+(25−5)×3/2%4

To evaluate the expression we follow the order of operations (PEMDAS/BODMAS).

Let's break down the expression:

  • Exponentiation (**): 10**2 (10 raised to the power of 2) = 100

  • Subtraction (-): 25−5 (25 minus 5) = 20

  • Multiplication (*): (25−5)×3 (result of subtraction multiplied by 3) = 60

  • Division (/): (25−5)×3/2 (result of multiplication divided by 2) = 30

  • Modulus (%): (25−5)×3/2%4 (remainder when dividing 30 by 4) = 2

  • Addition (+): 10**2 + (25−5)×3/2%4 (100 + 2 ) = 102

In the below example we are calculating simple interest using the Run expression operation.

The formula for simple interest (SI) is: Simple Interest (SI)=Principal×Rate×Time / 100.

Where you receive the value for principal amount, rate of interest, and time from the Webhook trigger:

1
{
2
"variables": {
3
"Principal amount": 1000,
4
"Rate of interest per year": 5,
5
"Time period in years": 2
6
}
7
}

Now for the operation to calculate simple interest you need to interpolate the jsonpaths in the place of variables in the formula.

Please disregard any warning signs.

1
{$.steps.trigger.body.variables.['Principal amount']} * {$.steps.trigger.body.variables.['Rate of interest per year']} * {$.steps.trigger.body.variables.['Time period in years']} /100

Subtract
Copy

The operation subtracts one number from another.

Both numbers' values can be obtained from previous workflow steps using jsonpaths.

Sum
Copy

The Sum operation calculates sum of a list of numbers.

To understand how to use the Math Helper connector's sum operation, consider a scenario where you have a list of test scores and you want to calculate the total of the scores:

1
{
2
"test_scores": [
3
85,
4
92,
5
78,
6
88,
7
95
8
]
9
}

You can reference the list of scores from previous workflow steps using jsonpaths.