Recently, I was working on a Salesforce flow to automate the process of sending an email based on a specific condition, such as the Account is Active and the Account Priority is either High or Medium.
When I was trying to add a condition in Flow, it did not allow me to use both ‘AND’ and ‘OR’ together in the Condition Requirement.
Since my requirement needed to check if the Account is Active (AND) and the Priority is High (OR) or Medium, I had to use a formula that allowed me to use both AND and OR operators simultaneously.
In this tutorial, we will learn how to use formulas in Salesforce Flow. I will explain where we can use formulas in Flow, important formula functions, and a list of all available formulas for Salesforce Flow, along with real-time examples and explanations.
Why We Use Formulas in Salesforce Flow?
A formula in Salesforce Flow is a way to write logic using fields, functions, and operators to generate a result, such as checking a condition, performing a calculation, or generating text values.
Formulas in Salesforce Flow are used to perform calculations, comparisons, and data manipulations. They allow us to generate new values based on existing data, check conditions, and set values to fields.
Now, let’s understand why we need to use formulas in Salesforce by taking an example: We want to calculate the difference between two dates and display the result in the field. At that time, we can use a formula in Salesforce Flow.
Important Formulas in Salesforce Flows
Below, I will explain some important formulas, along with their syntax and descriptions, that are commonly used in Salesforce flows.
| No | Function Name | Description | Example Formula |
| 1 | & | This is used to connect two different strings. | “Hello ” & {!$Record.FirstName} |
| 2 | IF() | This is a logical operator used to check a condition and display a message accordingly. | IF({!Amount} > 100000, “Large”, “Small”) |
| 3 | TODAY() | Today’s function represents the current date. Using it, we can add or remove days to get different dates from today. | TODAY() + 7 |
| 4 | AND() | Using the AND function, we can combine multiple conditions, and it returns TRUE if all conditions are true. | AND({!IsActive}, {!Amount} > 50000) |
| 5 | OR() | It returns TRUE if any of the conditions are true. | OR({!Status} = “Open”, {!Priority} = “High”) |
| 6 | ISPICKVAL() | This is used to check and compare the picklist values. | ISPICKVAL({!Stage}, “Prospecting”) |
| 7 | NOT(ISPICKVAL()) | When we want to ensure the picklist value we selected is not equal to ‘xyz’. | NOT(ISPICKVAL({!Type}, “Trial”)) |
| 8 | CONTAINS() | It is used to check if text includes a string. | CONTAINS({!Name}, “Urgent”) |
| 9 | ISBLANK() | It is used to check if the field contains any value. | ISBLANK({!Email}) |
| 10 | ISCHANGED() | This function executes only on a change of field values | Today’s function represents the current date. Using it, we can add or remove days to get different dates from today. |
List of All Available Formulas For Salesforce Flow
If you want to check all the formulas that support or are used in Salesforce Flow, then you need to write an SOQL query. There, you will find all the formulas and their descriptions.
Now, let’s review the formula functions available in Salesforce Flow. For that, we will write an SOQL query to display the formulas.
Below, I will explain the steps to retrieve the formulas and functions that are used in Salesforce Flow:
- Click Setup -> Developer Console.
- In the Query Editor, enter the following SOQL query:
SELECT Function.Name, Function.Label, Function.Description, Function.ExampleString
FROM FormulaFunctionAllowedType where Type='Flow'- Select the Use Tooling API checkbox.
- Click Execute.
In the image below, you can see the SOQL query result. It displayed the column that we provided in the query, and we can see the function that we can use in Salesforce flow, the description, and the syntax to use in the formula editor.

Formula Resource in Salesforce Flow
Now I will explain what a formula resource is and where we can use them in Flow elements.
What is the Formula Resource in Salesforce Flow?
In Salesforce Flow, a formula resource is a way to calculate a value using functions, fields, and operators available within the flow.
Here we can use expressions to define logic and generate a result. These resources are read-only and derive their value from the formula, not a directly set value.
Where can we use a Formula in Salesforce Flow?
We can use Formulas in elements of Salesforce Flow to perform calculations, set field values, and control the flow’s execution.
They are particularly useful for: Start element conditions, decision elements, and assignment elements.
Create Formula Resource in Salesforce Flow
Now, I will explain how to create the formula resource in the Flow builder using an example.
Suppose we want to set the opportunity close date to automatically update after 40 days of the creation date when creating the opportunity record.
To create a Formula Resource, click the Toolbox icon and then click the New Resource button.

As you click the Resource Type dropdown field, you will see various resources, such as Variable and Text Template. Here we need to select the Formula.
Provide the API Name. Whatever the formula we will use to calculate the values that will be stored in this name. Then, where we want to set this calculated value, we need to provide the API Name to the value field.
Now we need to select the Data Type based on the desired output value. That means, as per our example, we want to set the close date value. For that, I have selected ‘Date‘ as the data type.

Now, we need to create the logic using the fields, functions, and operators available in Salesforce Flow.
To validate our formula, click the Check Syntax button. If it displays a valid message, then our formula is correct, and you can click the Done button.

After creating the formula resource, you will see that it is listed under the Manager tab, with the API Name that you provided.

In this way, we can create the formula resource in Salesforce Flow.
How to Use Formulas in Salesforce Flow
Now, we will learn where we can create and use formulas in Salesforce Flow, including important functions for numbers, text, dates, and logic implementation, as well as how to utilize them in Action and Decision elements.
Example 1: Use AND() and OR() Functions in a Formula
Suppose you are implementing a flow to automate the process that should trigger only when an account is updated to the “Technology” industry, but only if the Priority is also “High” or “Urgent”.
In the image below, you can see that when we select the Condition Requirements, we can only choose either the AND or OR condition. We cannot use them together.

However, we can now select “Formula Evaluates to True” in the Condition Requirement option. There, we can create a formula and add to the value field.
A formula enables us to use logical operators such as ISCHANGED, AND, and OR, which we can’t easily do with the standard “All Conditions Are Met” option.
Here, I have developed a logic that allows us to validate both AND and OR function values simultaneously.
In this logical function, we have used two functions: ISCHANGED(), which checks if the field value has changed, and ISPICKVAL(), which determines if the account priority should be set to either High or Urgent.
AND(
ISCHANGED(Industry),
ISPICKVAL(Industry, "Technology"),
OR(
ISPICKVAL({!$Record.Account_Priority__c}, "High"),
ISPICKVAL({!$Record.Account_Priority__c}, "Urgent")
)
)To use the formula, select the “Formula Evaluate to True” option, and then we can create formulas for complex business logic that cannot be provided in simple conditions.

In this way, we can create and use AND() and OR() functions in a Formula in the Flow set entry condition in Salesforce to implement complex business logic conditions.
Example 2: Use TODAY() Function in Formula
Suppose a company wants to send a renewal reminder email, but only under specific conditions:
- The contract End Date is within the next 30 days.
- The contract Status is “Active”.
- And the Customer Type__c (Custom Picklist Field) is not “Trial“.
Here we have the Contract object in Salesforce. The Contract End Date is calculated based on the Contract Term (in months). Now we want to send a reminder email to those contracts whose end date will be within the next 30 days.

Navigate to the setup, and in the Quick Find box, search for ‘Flows’ under Process Automation.
In the flows setup window, click on the button New Flow. Select the option Schedule-Triggered Flow, and click Create.
Select the Start Date and Start Time for the schedule of the trigger flow. After this, select the frequency from the options: Once, Daily, and Weekly.

Now we need to create the formula resource, which we will use to check the conditions for sending the reminder email.
To create a formula in Flow Builder, click on “New Resource” in the Toolbox. Then choose “Formula” from the Resource Type dropdown. After that, provide the API Name and select the data type.
Here we will select Boolean as the Data Type because we want to send the email if the condition is true.

Next, you’ll see the screen where you can write your formula. If this formula evaluates as true, then the next step will be executed.
AND(
TODAY() + 30 >= {!$Record.EndDate},
ISPICKVAL({!$Record.Status}, "Activated"),
NOT(ISPICKVAL({!$Record.Customer_Type__c}, "Trial"))
)Below, I have explained the above formula:
- TODAY() + 30 >= {!$Record.EndDate}:
- This checks if the contract will end within the next 30 days.
- TODAY() is the current date.
- TODAY() + 30 means 30 days from now.
- If the End Date is before or equal to the current date, it indicates that the contract is nearing its end.
- ISPICKVAL({!$Record.Status}, “Activated”):
- This checks if the Status of the contract is exactly “Active”.
- ISPICKVAL() is used to check the value of picklist fields.
- NOT(ISPICKVAL({!$Record.Customer_Type__c}, “Trial”):
- This checks that the Customer Type is not “Trial”.
- The flow should only run for paying or regular customers, not for trial accounts.

After creating the formula, we need to add a decision element that checks if the created formula returns true. If it does, we can send the reminder email.
If the formula gets false, then the Default Outcome will be executed.
After adding the decision element, provide the Label and API Name. Next, add the Outcome Label as per your requirement.
Select the Formula Resource that we created in the Resource field. In Operator, select Equals, and Value is True.
This condition says that if the formula that you created is true, then the next step will be executed.

If the condition is true, the Send Email action will be executed, sending a reminder email to the customer.
After sending an email, we will update the ‘Reminder Sent‘ checkbox field to True. That will indicate a reminder has been sent to this contract owner.
Now we are ready to save the flow. For that, click the Save button, provide the flow Label, and the API Name will be automatically populated.
After that, always debug the flow before activating it to ensure that the working flow is correct and that there are no runtime errors. Then activate the flow.

In this way, we can TODAY() function in Salesforce Flow Formula with a decision element.
Example 3: Use IF() Function in Formula
A software company offers different discount messages based on the Opportunity Amount. When a sales rep creates or updates an opportunity, the system should automatically generate a custom discount message and display it on the custom field named Discount_Message__c.
- If Amount >= 100,000 -> Message: “Eligible for 20% enterprise discount.”
- If Amount < 100,000 but >= 50,000 -> Message: “Eligible for 10% business discount.”
- Otherwise -> Message: “Standard pricing applies.”
Create the Record Trigger Flow and configure the Start Element as follows:
- Object: Opportunity.
- Trigger: When a record is created or updated.
- Optimize the Flow For: Actions and Related Records.
Create a formula resource that allows us to add a condition to the opportunity amount field and also display a corresponding message based on the condition.
For this Formula, which is one of the Resource Types, we have selected the Data Type as Text.

Next, we need to provide the formula and the message that we want to display according to the opportunity amount.
IF(
{!$Record.Amount} >= 100000,
"Eligible for 20% enterprise discount.",
IF(
{!$Record.Amount} >= 50000,
"Eligible for 10% business discount.",
"Standard pricing applies."
)
)After adding the formula, always check the Syntax. If it is valid, you can click the Done button; if it is not, you need to make corrections to your formula.

After creating the formula, we need to create a Variable resource with a Data Type of Text that will hold the discount message received from the formula resource.

The discount message received from the formula resource, we need to assign it to the Text variable that we created in the above step.

Then, finally, we need to update the discount message field in the opportunity object. For that, add the Update Record element and set the varDiscountMessage variable to the field of the opportunity object.

After that, save and activate the flow.
Next in the opportunity object, you can see we don’t have any text in the Discount Message field.
Now, as I update the Amount field and save the record, the discount message field automatically displays the message according to the condition we defined in the formula resource.

You can see that as I saved the record, the discount message is displayed.

In this way, we can use the formula with an assignment element in Salesforce Flow to set the value of a variable.
Example 4: Use YEAR(), MONTH(), and DAY() Functions in Formula
A company wants to send a special email to employees on their birthday, but only once a year.
Here, the DOB field on the employee object is the Date field, which stores the value in the format ‘DD/MM/YYYY‘. From this date, we need to extract the month and the date of the employee.
Here is the formula that will extract the birthday month and day from the DOB field of the employee object.
Then we compared the day and month with today’s day and month.
AND(
MONTH({!Get_Employees.DOB__c}) = MONTH(TODAY()),
DAY({!Get_Employees.DOB__c}) = DAY(TODAY())
)Here, we selected the Data Type as Boolean because the condition we added is that if it is true, then today is the employee’s birthday.

In the decision element, we validate the condition: if the formula evaluates to true, then send the email to that particular customer.

In this way, we can use the YEAR(), MONTH(), and DAY() functions in Salesforce Flow formula to extract the value from the date field.
Example 5: Use VALUE(text field) Functions in Formula
The VALUE(text field) function in Salesforce Flow is specifically used to convert text (string) into a number (numeric type), such as an integer or decimal, so that it can be used in mathematical operations or comparisons.
Suppose the company uses a Screen Flow where a user enters a discount amount as a text input (maybe because it’s coming from an external source as text).
Now, we want to subtract that discount from the Opportunity Amount and show the final payable amount.
Here, you can see that we have the Data Type of the Discount Amount field set to Text. That means that when we enter a number in this field, it is stored as text.

Also, in the screen element, we need to add the text component to accept the discount amount value.

Now we need to create a formula to calculate the Final Payable Amount, which is a numeric value of type Number.
Now, when we add the formula for subtraction from Total Amount( numeric field) – Discount Amount( text field) and click the Check Syntax, it throws an error.
Because we are trying to subtract text from a number.

To resolve this error, we need to convert the text into a number. For that, we added the VALUE() function and passed the text field into it.
Next, as we check the syntax, it shows valid.

In this way, we can use the VALUE(text) function in Salesforce flow formula to convert the text field to a number field for calculations or comparison purposes.
Conclusion
I hope you have an idea about how to use formulas in Salesforce Flow. I have explained where we can use formulas in Flow, essential formula functions, and a list of all available formulas for Salesforce Flow, along with real-time examples and explanations.
You may like to read:
- Flow User Checkbox vs Run Flows in Salesforce
- Create and Use recordId Variable in Salesforce Flow
- Wait Element in Salesforce Flow
- Check if Get Records Is Empty in Salesforce Flow
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.