---
schema_version: "1"
id: 9d2d2b24e24d906640bd63cc6c2be4e11de8463764870b7c6eb2d128fae887e3
title: Formula Best Practices
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/customize_formula_best_practices.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.customize_formula_best_practices.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: d2f80b1b2a05750f5e09c99ada1f89772111565479a6a9f844c0b5cb387169a9
description: You can use the Formula Editor in Salesforce to construct a simple formula with a few clicks. But what if you want to build something more complex? Use these tips to help you map out formula logic and make it easier to troubleshoot errors.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Formula Best Practices

You can use the Formula Editor in Salesforce to construct a simple formula with a few clicks. But what if you want to build something more complex? Use these tips to help you map out formula logic and make it easier to troubleshoot errors.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: both Salesforce Classic and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: all editions</td></tr></tbody></table>

![Thank you](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_note.png)

Thank you Special thanks to [Trailblazer Chris Emmett](https://success.salesforce.com/ProfileView?u=0053A00000COCjIQAX) for contributing this content.

## Tip 1: Put Every Function on a Separate Line

It’s easy to fall into the habit of keeping an entire formula on a single line, especially when the formula is small. Putting each function on its own line makes the formula easier to read and troubleshoot. These examples show the same formula, first with no line breaks, and then with each function on a separate line.

`IF(AND(ISBLANK(myDate_c),active_c=true),"Missing Date","Not Applicable")`

`IF( AND( ISBLANK(myDate_c), active_c=true ), "Missing Date", "Not Applicable" )`

## Tip 2: Indent Sections Within Parentheses

When your formula involves multiple functions, indentation helps visually isolate each function and makes it easier to identify errors, such as misplaced characters.

In this example, with indentation, you see that the bulk of the formula sits within a single `IF` statement and that the `AND` statement contains two functions. Inside the `AND` statement, the function `ISBLANK` is enclosed in parentheses.

`IF(   AND(     ISBLANK(myDate_c),     active_c=true   ),   "Missing Date",   "Not Applicable" )`

Indentation can also help you zero in on mistakes. With a flat layout, it’s difficult to see that an extra “`)`” is included after the `ISBLANK` statement, and there are no visual clues about how the formula is structured.

`IF( AND( ISBLANK(myDate_c) ), active_c=true ), "Missing Date", "Not Applicable" )`

The indented layout makes it easy to see the formula’s structure. You can quickly find and remove the extra character so that the `AND` statement is correctly formatted.

`IF(   AND(     ISBLANK(myDate_c)     ),     active_c=true   ),   "Missing Date",   "Not Applicable" )`

## Tip 3: Write Statement and Function Names in Uppercase

All the examples here use uppercase letters for statement and function names, such as `IF`, `AND`, and `ISBLANK`. Using uppercase for these terms creates a clear distinction between functions and parameters and brings some visual clarity to a complex formula.

## Tip 4: Handle Null and Required Input Field Values

These examples reference a field called `myDate__c` and use the `ISBLANK` check to confirm that the field is populated. It’s important to verify the contents of any field in a formula. Without this verification, a formula can fail. For example, if you add a second date to the formula and perform a greater than operation, include the `ISBLANK` check for the second date to ensure that the formula executes correctly.

`IF(   AND(     ISBLANK(myDate__c),     ISBLANK(mySecondDate__c),     active__c=true,     mySecondDate__c > myDate__c   ),   "Missing Date",   "Not Applicable" )`

## Tip 5: Use the HYPERLINK() Function to Create URLs

To create valid clickable links in Formula fields, use the `HYPERLINK()` function. This function is a TEXT function with syntax

`HYPERLINK(URL, link_name [,target])`