Math functions
In this guide, we’ll explore the math functions available in Make.com. These functions will help you handle various numerical tasks, from basic calculations to more detailed analysis.
We’ll cover functions for summing values, rounding numbers, calculating averages, and more. Understanding these will help you to work with numbers in your scenarios.
Table of Contents
Ready to crunch some numbers? 😄
Introduction to math functions
This is what the mapping panel looks like for the math functions;
As you can see, the panel is divided in three sections:
- Variables: handy for when you need a random number or pi.
- Functions: all the ways you can play with numeric values
- Operators: you can add these to your formulas to alter what a function is doing.
You can click on each one to add them to a field in a module or filter.
All math functions explained
sum
The sum() function returns a total sum of all numbers in it.
sum(2;5)
= 7
sum(1;2;900)
= 913
And you can use items or arrays in it too.
sum(1.item;1.another_item;1.third_item)
= 7
sum(1.array[])
= 913
average
average()
returns the average value of the numeric values.
You can enter the numbers individually, map items with numbers, or get the average of a specific array.
average(1;2;3;4;5)
= 3
average(1.3;4;2;3.4)
= 2.97
But you can also map items instead of manually typing numbers, here is an example:
age_group1
=35
age_group2
=50
age_group3
=62
average(1.age_group1;1.age_group2;1.age_group3)
= 49
Now with an array.
Let’s say we have an array called product_price
with the values [10, 20, 30, 40, 50]
.
average(1.product_price[])
= 30
As you can see, it works exactly the same as if you were to enter the numbers individually.
round
round()
rounds a numeric value to the nearest integer.
round(1.2)
= 1
round(1.5)
= 2
round(1.7)
= 2
round(2)
= 2
ceil
The ceil(number)
function rounds a number up to the next whole number, or the number stays the same if it’s already a whole number
ceil(1.3)
= 2
ceil(6)
= 6
floor
Does the opposite of the ceil()
function because floor()
returns the previous whole number, or the number stays the same if it’s already a whole number.
floor(1.3)
= 1
floor(6)
= 6
max
This is my favorite because it’s my name 🤭
max()
returns the largest value of the numeric values.
You can enter the numbers individually, map items with numbers, or get the average of a specific array.
Here we enter them manually;
max(1;5;3)
= 5
Now let’s say we have some items that have a value of the sales for each month;
sales_january
–8623
sales_february
–7365
sales_march
–2826
max(1.sales_january;1.sales_february;1.sales_march)
= 8623
Our you could get the highest number out of an array. For example the array sold_items
contains [183, 932, 283, 2]
max(1.sold_items[])
= 932
min
min()
returns the smallest number in a specified array, or the smallest number among numbers entered individually.
min(1;2;3)
= 1
min(1.array[])
= 5
median
median()
returns the median of the values in a specified array, or the median of numbers entered individually.
median(3;5;7)
= 5
median(2.5;3.5;2;4.5;1)
= 2.5
median(1.array[])
= 4
parseNumber
This is especially handy if your region uses the ,
decimal separator because the default in Make.com is a .
decimal separator.
.
(Dot): Commonly used in countries like the United States, Canada, and Australia.,
(Comma): Commonly used in countries across Europe, including Germany, France, and Spain.
For example:
- US: 1,234.56
- Germany: 1.234,56
Yeah, they couldn’t have made it more confusing, right? 😋
So the parseNumber()
function parses a number and returns the same number with the .
decimal separator.
parseNumber(12,99;,)
= 12.99
parseNumber(1.234,56;,)
= 1234.56
You first enter the number you want to parse, and then the decimal separator the number is currently using.
formatNumber
formatNumber is slightly more complex because you can enter so many things, but it’s very handy to get a number in the requested format.
Here is an example;
formatNumber(123456789;3;,;.)
= 123.456.789,000
- 1st part: the number you want to format.
- 2nd part: then the amount of decimal points
- 3rd part: the decimal separator
- 4th part: the thousands sepraator.
Lets say we have the number 11055.3928
and we would like to have only two decimal points, and also have a thousands separator;
formatNumber(11283.3988;3;,;.)
= 11,283.40
See how it also rounded ,3988
up to ,40
? That’s also what it’s handy for.
And maybe also handy to know is that the default decimal separator is ,
and thousand separator is .
So if you only enter the number and amount of decimal points, this happens;
formatNumber(1022.129;2)
= 1.022,13
Getting the error below while trying to format your number?
DataError: Failed to map ‘value’: Function ‘formatNumber’ finished with error! ‘NaN’ is not a valid number or using unsuitable separator.
Then you need to use parseNumber()
first because it didn’t understand the number format you gave it.
formatNumber(parseNumber(10100,23;,) ;2;.;,)
= 10,100.23
stdevP
stdevP()
returns the standard deviation of a specified array of population values, or the standard deviation of numbers entered individually.
stdevP(1;2;3;4;5)
= 1.4142135623730951
stdevS
stdevS()
returns the standard deviation of a specified array of sample values, or the standard deviation of numbers entered individually.
stdevS(1;2;3;4;5)
= 1.5811388300841898
trunc
trunc()
truncates a number to an integer by removing the fractional part. You can optionally specify the number of decimal places to keep.
trunc(3.789)
= 3
trunc(3.789;2)
= 3.78
trunc(-3.789;2)
= -3.78
trunc(123.456,-2)
= 100
abs
abs(number)
returns the absolute value of a specified number. The absolute value is the non-negative value of the number.
abs(-3)
= 3
abs(9)
= 9
abs(0)
= 0
abs(-12.4)
= 12.4
This function is often used in financial calculations to measure the absolute value of changes or differences, regardless of their direction.
Using operators
At the bottom of the mapping panel for the math functions, you can see the operators marked in green.
Some of them are pretty straightforward, like +
which will simply add up two or more values, but you might not be familiar with a few others.
Let me explain how they work before we dive into each one of them.
To use an operator, you can simply add it to your field and numbers without any parenthesis or functions.
1+3
= 4
But as soon as you want to do anything else in that field, you need to add parenthesis ()
.
But it’s important that you don’t just type parenthesis, get the ()
from the general functions.
I am (1+3) years old
= I am 4 years old
And you would do the same if you want to combine operators.
(1+3)–2
= 2
I am ((1+3)-2) years old
= I am 2 years old
Got it? 😄
Let me explain each operator in the next section.
Multiplication (*)
Multiplication is a mathematical operation that represents the repeated addition of a number.
4*3
= 12
5*6
= 30
7*2
= 14
You can use multiplication in other formulas or calculations by wrapping the expression in ( )
.
Remember, multiplication is commutative, meaning that the order of the numbers does not matter: a * b
is the same as b * a
.
(3*4) is the total when you add 4 three times
= 12 is the total when you add 4 three times
Multiplication can also be used with variables and items.
number_of_pizzas
=4
price_per_pizza
=10
(1.number_of_pizzas*1.price_per_pizza)
= 40
Division (/)
Divides one number by another.
10/2
= 5
100/5/2
= 10
Uou can use it directly unless combining it with other operations.
For more complex calculations, wrap them in parentheses ( )
to make it work.
I have (30/5) apples
= I have 6 apples
Division also works with numbers stored in items.
total_funds
=1000
people_count
=4
(1000.total_funds/4.people_count)
= 250
Modulo (mod)
The modulo operator finds out what’s left over after dividing one number by another.
For example, if you have 20
cookies and share them with 3
friends, each friend gets 6
cookies, totaling 18
cookies. You’ll have 2
cookies left over, which is the remainder, so the modulo is 2
.
(whoahh, flashback to school!)
20mod6
= 2
Another example where we have nothing left;
20mod5
= 0
When using it with text or other operators, use parentheses ( )
to keep calculations working.
I have (20mod6) cookies left
= I have 2 cookies left
Modulo can also be used with numbers in items.
total_items
=35
group_size
=7
(35.total_itemsmod7.group_size)
= 0
Addition (+)
Simply adds up two or more numbers.
1+2
= 3
1+2+5+90.2
= 98.2
As you can see, you can just use it without any formulas or brackets in a field.
But as soon as you want to do something else in that field too, you need surround it with parentheses ( )
to make it work.
My favorite number is (2+3)
= My favorite number is 5
And you use the parentheses to combine it with other operators too.
(2+3)–2
= 3
I have build ((2+3)–2) scenarios in Make
= I have build 3 scenarios in Make
And here is an example how it would work with items from previous modules;
amount_shirts
=15
amount_shoes
=7
(1.amount_shirts+1.amount_shoes)
= 22
Subtraction (–)
Subtracts one number from another.
5–2
= 3
100–50–20
= 30
Just like with addition, you can use it freely without brackets unless you want to combine it with other operations.
To mix it with other operations, wrap it in parentheses ( )
to make it work.
I have (10–3) cookies left
= I have 7 cookies left
Subtraction also works with numbers stored in items.
new_coffee
=200
old_coffee
=80
(10.new_coffee–5.old_coffee)
= 120
Lower than (<)
The lower than operator (<
) compares two numbers and checks if the first number is smaller than the second number and returns true
or false
.
It’s basically asking is first number
smaller than second number
? True or false.
5<10
= true
15<8
= false
Want to use it in a text or other formula? Don’t forget to wrap it in ()
.
For example:
It’s (8<10) that first number is smaller than the second number
= It’s true that the first number is smaller than the second number
It’s (8<5) the first number is smaller than the second number
= It’s false the first number is smaller than the second number
The lower than operator can also be used with variables and items.
current_temperature
=18
threshold_temperature
=20
(1.current_temperature<1.threshold_temperature)
= true
Handy, right? 😄
Lower than or equal to (<=)
Very similar to the lower than operator, but now we’re also checking if it’s equal.
So (<=
) compares two numbers and checks if the first number is smaller than or equal to the second number, returning true
or false
.
It’s basically asking: is first number
less than or equal to second number
? True or false.
5<=10
= true
15<=8
= false
15<=15
= true
And you can use it in other formulas or within text by wrapping the calculation in ( )
.
Remember, you have to get these in the general functions tab and can’t type them yourself.
It’s (8<=10) that the first number is less than or equal to the second number
= It’s true that the first number is less than or equal to the second number
The lower than or equal to operator can also be used with variables and items.
current_age
=30
age_limit
=35
(1.current_age<=1.age_limit)
= true
Greater than (>)
This operator checks if the first number is greater than the second number.
It’s basically asking: is first number
greater than second number
? True or false.
15>10
= true
5>8
= false
10>10
= false
And you can use it in other formulas or within text by wrapping the calculation in ( )
.
Remember, you have to get these parentheses in the general functions tab and can’t type them yourself.
It’s (12>10) that the first number is greater than the second number
= It’s true that the first number is greater than the second number
The greater than operator can also be used with variables and items.
current_age
=30
age_limit
=25
(1.current_age>1.age_limit)
= true
Greater than or equal to (>=)
The greater than or equal to operator (>=
) compares two numbers and checks if the first number is larger than or equal to the second number, returning true
or false
.
It’s basically asking: is first number
greater than or equal to second number
? True or false.
10>=5
= true
7>=10
= false
8>=8
= true
And you can use it in other formulas or within text by wrapping the calculation in ( )
.
Remember, you have to get these in the general functions tab and can’t type them yourself.
It’s (10>=8) that the first number is greater than or equal to the second number
= It’s true that the first number is greater than or equal to the second number
The greater than or equal to operator can also be used with variables and items.
current_age
=30
age_limit
=25
(1.current_age>=1.age_limit)
= true
Using variables
There are only two math variables; random
and pi
.
You can insert these into your formula to insert a random number or pi.
Random
Inserts a random number between 0
and 1
with 16 decimals.
random
= 0.8784728627922098
random
= 0.5489120946325066
See? Every time we run the scenario another number is shown.
Want to simplify it, and have a random number between 1 and 10? Multiply it with 10 and use the round()
function to get the nearest round number.
round(random*10)
= 7
round(random*10)
= 3
This is actually a really cool feature, and you can use it for plenty of things.
Some people like to, for example, use it to make the data go through different routers in a scenario randomly.
Pi
Handy in case you need pi 🙂
pi
= 3.141592653589793
Wanna calculate the circumference of a large pizza with a diameter of 2 meter? Here’s how:
pi*2
= 6.283185307179586
Conclusion
Math Functions in Make.com are handy to make any kind of calculation that you need, and they’re incredibly flexible.
You can use them inside modules, filters, anything you want really.