Build and use formulas

You can build and use formulas to calculate different data using contact attributes and transactional parameters.

Before you start

Make sure you're familiar with the different types of contact attributes.

How to build a formula?

In Brevo, the two basic functions to build formulas are COUNT and SUM.

COUNT: Count specific data

The COUNT function can be used to count specific data.

COUNT[A] Will count the number of A.
COUNT[A,B,C,D]
A is mandatory; B, C, and D are optional.
Will count the number of A, use B as a first condition, use C as an operator (=, < or >), and use D as a second condition.

SUM: Calculate the total value of specific data

💡 Good to know
You cannot use a text attribute with a SUM function.

The SUM function can be used to calculate the total value of specific data.

SUM[A] Will calculate the total value of A.
SUM[A,B,C,D]
A is mandatory; B, C, and D are optional. D can be a fixed number or can be used with the command NOW where NOW(-x) is the date from x days ago.
Will calculate the total value of A, use B as a first condition, use C as an operator (=, < or >), and use D as a second condition.

How to use formulas?

Calculated values

A formula can be used in a calculated value to calculate specific data for each of your contacts using transactional parameters. Calculated values are displayed on your contacts' details page. You can create up to 50 calculated attributes per Brevo account.

To learn how to add calculated values, check our dedicated article What are the different types of contact attributes?.

mceclip0.png

➡️  For example
If you are using the transactional parameter ORDER_ID to store orders, ORDER_VALUE to store the total amount of orders, and ORDER_DATE to store the order date:
  • COUNT[ORDER_ID]: count the total number of orders made by a contact.
  • COUNT[ORDER_ID,ORDER_VALUE,>,50]: count the total number of orders over 50€ made by a contact.
  • SUM[ORDER_VALUE]: calculate the total value of orders made by a contact.
  • SUM[ORDER_VALUE,ORDER_DATE,>,NOW(-30)]: calculate the total value of orders made in the past 30 days by a contact. 

Global calculated values

A formula can be used in a global calculated value to calculate custom statistics for your contact lists and emails using contact attributes. Global calculated values are displayed under the Global Computed Values section of your dashboard. You can create up to 30 global calculated attributes per Brevo account.

To learn how to add a global calculated value, check our dedicated article Can I add custom statistics to calculate?.

mceclip0.png

➡️  For example
  • COUNT[BLACKLISTED,BLACKLISTED,<,NOW()]: count all blocklisted contacts until now.
  • COUNT[BOUNCES,SOFT,<,NOW(-30)]: count all soft bounces in the last 30 days.
  • COUNT[BOUNCES,HARD,<,NOW()]: count all hard bounces until now.
  • COUNT[READS,READS,<,NOW(-15)]: count all opens in the last 15 days.
  • COUNT[READERS,READERS,<,NOW()]: count all unique opens until now.
  • COUNT[CLICKS,CLICKS,<,NOW(-60)]: count all clicks in the last 60 days.
  • COUNT[CLICKERS,CLICKERS,<,NOW()]: count all unique clicks until now.

🤔 Have a question?

If you have a question, feel free to contact our support team by creating a ticket from your account. If you don't have an account yet, you can contact us here.

If you’re looking for help with a project using Brevo, we can match you with the right certified Brevo expert partner.

💬 Was this article helpful?

8 out of 39 found this helpful