Salesforce Flow Formulas: 5 Useful Examples (Text, Date, IF)

flows Feb 10, 2025

Are you a Salesforce admin looking for quick solutions to common Salesforce Flow formulas problems? You’re in the right place. In this help guide, we’ll walk through 5 useful Salesforce Flow formula examples that you can plug into your flows right away. We focus on text manipulation, date calculations, and IF logic – the areas where beginner and intermediate Salesforce professionals often need help. There are countless formula functions available (text, logical, date, etc.)​, but here we’ve distilled some of the most practical ones for everyday use. Each example comes with a ready-to-use formula, a brief explanation, and step-by-step instructions. Let’s dive in and make Flow formulas simple!

1. Combine Text Fields into a Full Name

Use case: You have separate First Name and Last Name values and want to combine them into one string (e.g. for a greeting or a single-line display). This is a basic text manipulation formula that concatenates two text fields with a space in between.

How to do it:

  1. Create a Text Formula Resource: In Flow Builder, add a new Formula resource (Text type) to hold the full name.
  2. Build the Formula: Use the concatenation operator & (or +) to join first name, a space, and last name. For example:

    {!Contact.FirstName} & " " & {!Contact.LastName}
     
     
    This formula simply connects the FirstName and LastName with a space​. (In Salesforce formulas, & and + both concatenate strings​.)
  3. Use the Result: The formula will output something like "John Doe". You can use this FullName formula resource later in your flow – for instance, in an Assignment to set a field, or in a Screen component to display a full name.

Why it’s useful: Instead of manually joining text in each flow, one formula handles it. This saves time and ensures consistency. You can concatenate any text fields or even literal strings. For example, to include a salutation you might do: "Hello, " & {!Contact.FirstName} & "!" as a quick greeting.

2. Default a Text Value If a Field is Blank

Use case: Sometimes a field might be empty, and you want to use a default value in that case. For example, if a contact’s Title is blank, you might want to display "N/A" or some placeholder. We can do this using an IF check or the BLANKVALUE() function in a flow formula.

How to do it:

  1. Create a Text Formula Resource: Add a new Formula resource of type Text for your default logic (or you can directly use such a formula in a Decision element as the condition).
  2. Write the Formula: Use BLANKVALUE(field, default) which returns the field’s value if it’s not blank, or the default if it is blank​. For example:
     
     
    BLANKVALUE({!Contact.Title}, "N/A")
     
     
    This formula checks the Contact Title. If Title is blank or null, it will yield "N/A". Otherwise, it will return the actual Title value​. (Behind the scenes, BLANKVALUE(X, Y) is equivalent to IF(ISBLANK(X), Y, X).)
  3. Use the Result: Now you can use this formula in your flow wherever needed. For instance, on a Screen element to show a user’s title or "N/A" if no title is set, or in an Assignment to populate a field with a default value.

Why it’s useful: This formula prevents blank values from causing issues or ugly displays. Beginner admins often struggle with handling empty fields – this provides an easy solution. You can adapt the default text as needed (e.g., "Unknown" or "Not Provided"). It’s immediately usable in any scenario where you need a fallback for blank inputs.

3. Check If Text Contains a Value (Using IF + CONTAINS)

Use case: You want to make a decision in your flow based on whether a text field contains a certain substring. For example, suppose on Opportunity you want to set a Priority flag if the Type field contains the word "Existing". The CONTAINS function with an IF statement is perfect for this.

How to do it:

  1. Prepare the Field Value: Ensure you have the text you want to check. If it’s a picklist in Salesforce, convert it to text using the TEXT() function inside your formula. (Flow formulas require converting picklist values to text before using text functions.)
  2. Create a Formula Resource (Text or Boolean): If you want a text output like "High" or "Medium", make a Text formula resource. If you just need a true/false condition, you could make it Boolean. In our example, we’ll output a text Priority.
  3. Write the Formula: Use the IF function combined with CONTAINS(). For example:
     
     
    IF( CONTAINS( TEXT({!Opportunity.Type}), "Existing"), "High", "Medium" )
     
     
    This checks if the Opportunity Type (picklist) text includes "Existing". If yes, it returns "High", otherwise "Medium"​. (In a real scenario, you might set "High Priority" for existing customers.)
  4. Use the Result: You can use this formula’s output to set a Priority field, display a message, or drive a Decision element. For instance, a Decision could check if the formula result equals "High" and then branch the flow accordingly.

Why it’s useful: This pattern—IF CONTAINS—is handy for many scenarios: checking if an email address contains "gmail.com", if a description field mentions "urgent", etc. It demonstrates combining text functions and logic. Keep in mind that CONTAINS() is case sensitive and does not work on multi-select picklists (for multi-select, use INCLUDES() instead)​. By using TEXT() on picklists, as shown above, you ensure the function works properly on picklist values.

4. Calculate the Number of Days Between Two Dates

Use case: You need to perform a date calculation in your flow, such as finding the duration (in days) between two dates. For example, you might want to know how many days are left between Today and a target Due Date, or the length of time between a Start Date and End Date on a project.

How to do it:

  1. Determine Your Date Fields: Identify the two date values you want to compare (e.g., Start_Date__c and End_Date__c, or $Flow.CurrentDate for today’s date in a flow).
  2. Create a Number Formula Resource: Add a Formula resource of type Number (with zero decimal places) to calculate the difference.
  3. Write the Formula: Simply subtract one date from the other. In Salesforce formulas, subtracting two Date values gives the difference in days​. For example:
     
     
    {!End_Date__c} - {!Start_Date__c}

    If End Date is 2025-12-31 and Start Date is 2025-12-25, the result will be 6 (days). If you use Today’s date, e.g. Due_Date__c - TODAY(), you’ll get the number of days from today until the due date. (A negative result means the date is in the past.)
  4. Use the Result: The output is a number. You can use it in a Decision (e.g., if result > 0, still open; if < 0, overdue) or display it in a screen. For instance, you might show “Project duration is X days” or use it to trigger an alert if the number of days remaining is below a threshold.

Why it’s useful: Calculating date differences is a common requirement (e.g., how many days until an opportunity closes, or the age of a case). Instead of writing Apex or doing this math offline, a simple Flow formula does it instantly. This example shows that Flow formulas can handle date arithmetic directly – a big win for automation. For more date tricks, remember functions like ADDMONTHS(date, n) to add months accurately​, or extracting parts of a date with YEAR(), MONTH(), DAY() if needed.

5. Flag Overdue Tasks with an IF Date Comparison

Use case: You want to set a text or boolean flag if a date has passed relative to today. A classic example: mark a Task or Case as "Overdue" if its Due_Date__c is earlier than today. This uses an IF statement with the TODAY() function in a formula.

How to do it:

  1. Create a Formula (Text or Checkbox): If you want a text output like "Overdue"/"On Track", use a Text formula resource. If you prefer a checkbox (true/false), use a Boolean formula.
  2. Write the Formula: Use IF to compare the date to today. For example:
     
    IF( TODAY() > {!Task.Due_Date__c}, "Overdue", "On Track" )
     
     
    This formula checks if today’s date is greater than the Task’s Due_Date. If yes (meaning the due date is in the past), the formula returns "Overdue"; otherwise it returns "On Track"​.
  3. Use the Result: This formula can drive a Decision in a flow (e.g., proceed down an “Overdue” path), or simply write the result to a field. If you created a Boolean formula instead, it would return true/false – that could directly feed a Decision element or update a checkbox field “Is Overdue”. For example, you might update a Task record’s Status to “Expired” if this formula outputs "Overdue".

Why it’s useful: This showcases IF logic with dates – a very common need. Rather than manually calculating or writing script, the formula instantly evaluates the status. You can adjust the outputs as needed (e.g., "Yes"/"No" or a different wording). This pattern can be reused for any deadline or expiry checks in your org. It’s immediately usable for things like highlighting overdue opportunities, contracts past end date, etc. (Tip: You could even extend it with additional conditions using AND or OR if needed, such as checking a status field along with the date.)

Additional Tips for Flow Formulas

  • Formula Data Types: Remember to set the formula resource’s data type appropriately (Text, Number, Date, Boolean, etc.) based on what you want to return. A mismatched type can cause errors in Flow. For instance, an IF formula that returns "Overdue"/"On Track" must be Text type.
  • Testing: Use the Flow debugger or a Screen to output your formula result when building, to ensure it behaves as expected. A small typo can break a formula, so testing is key (the Flow debug will show formula outcomes).
  • Use Global Constants: In Flow, you also have global constants like $Flow.CurrentDate and $Flow.CurrentDateTime which are equivalent to TODAY() and NOW()​. You can use them in formulas if you prefer that style.
  • Complex Logic: If you find yourself writing very complex formulas, consider whether you should break the problem into multiple formula resources or use a Decision element. Sometimes a formula isn’t the only solution – but for many simple calculations, text formatting, or IF/OR conditions, formulas keep your flow streamlined.

For more on building efficient flows, check out our guide on Salesforce Flow Best Practices for Efficient and Scalable Automation. And if you’re new to Flow Builder, you might find Salesforce Flow Types Explained helpful to understand the different types of flows and when to use them.

Conclusion & Next Steps

By now, you’ve got five ready-to-use Salesforce Flow formulas under your belt – covering text concatenation, default values for blanks, conditional logic with CONTAINS, date arithmetic, and IF statements with dates. These are some of the most common needs for Salesforce admins automating with Flow. Feel free to tweak these examples to fit your org’s requirements. The key is knowing that with a bit of formula magic, you can point-and-click your way to powerful logic in Flow (no Apex needed!).

Ready to become a Flow formula pro? Keep practicing these techniques and explore more scenarios. And if you want to master Salesforce Flows end-to-end, including advanced formulas and best practices, consider enrolling in our comprehensive Salesforce Flow course. In the course, we dive deeper into real-world Flow challenges and teach you how to design automations like a pro. Enroll in the 2025 Salesforce Flows course today and take your skills to the next level! Good luck, and happy Flow-building!

Salesforce Saturdays

Join the Salesforce Saturday newsletter. Every Saturday, you'll get 1 actionable tip on Salesforce technology or career growth related to the Salesforce Industry.

We hate SPAM. We will never sell your information, for any reason.