Recently, I worked at a company that used Salesforce as its CRM application. One day, I was tasked with displaying a message showing the number of days left until the subscription expires.
As a solution, I found that Salesforce provides a function named TEXT, which helped me display this text message. If you want to learn how to use the TEXT() function in Salesforce, let’s deep dive into this tutorial and learn with examples.
In this tutorial, we will learn how to use the TEXT() function in Salesforce to convert a value to text using the standard display format. We will also learn its syntax and a few real-world business-related useful examples.
What is the TEXT() Function in Salesforce
The TEXT() function in Salesforce is one of the text functions available in Salesforce and is used to perform text operations. In basic terms, the TEXT() function is used to display or modify data in a textual format.
In other words, this TEXT() function converts data from the per cent, number, date, date/time, currency, and picklist field types into a text field type.
The syntax of the TEXT() function is as follows:
TEXT(value)Here, the value parameters specify the value or field to transform into text. It could be a constant value, a formula, or a field reference.
For a better understanding of how the TEXT function works, let’s look at an example.
As I mentioned above, I need to display a message showing the number of days left until the subscription expires. Therefore, I will utilise Salesforce TEXT() function for this. The formula is as given below:
IF(
Subscription_Expiry_Date__c >= TODAY(),
"Product Expired",
"Number of Days Remaining: " & TEXT(Subscription_Expiry_Date__c - TODAY())
)With this, we learned the syntax of the TEXT() function and an example. We’ll now look at how to use the TEXT() function in Salesforce.
Use the TEXT() Function in Salesforce
The following steps show how to use the TEXT() function in Salesforce.
- Open Salesforce Lightning mode. Next, click the “Gear Icon” in the top right corner of the page. Click “Setup“ from the dropdown menu to continue.

- The setup page opens when you select the Setup option. Here, the “Object Manager” is found in the Navigation Bar next to the Home tab. Click on it.

- The object manager page opens when you click it. There are numerous objects seen here. Use the Quick Find search field to find the item on which we want to use the TEXT() function.
- In this instance, I look for the “Product” object because I need to convert the product price to text and also concatenate the USD text to it.
- Now, click the “Product” object to move to the product object page.
- In this instance, I look for the “Product” object because I need to convert the product price to text and also concatenate the USD text to it.

- On the product object page, the “Field & Relationship“ option is in the details section on the left side. Select “Field & Relationship” from the menu.
- The field and relationships page is opened after selecting the field and relationship option. Click the “New” button at the top of the page.

- The field type page opens when you click the new button. The page contains a wide variety of field types. In this case, I chose the “Formula” field type, as I want to use the TEXT function in the advanced formula.
- Click the “Next” button to move on to the next step.

- The choose output type screen appears after clicking the next button. Enter the information now by filling out the “Field Label” and the “Field Name”, which is automatically filled in when you put the cursor on the field name. In this instance, I typed “Total Product Price” into the field label.
- Choose the “Output Data Type“ for the field in which we want to store the result. In this case, I check the radio button next to the “Text” data type to return the formula result as text.
- Move to the next step by clicking the “Next” button.

- Go to the advanced formula editor and enter the TEXT() function formula there. In this instance, I want to use the TEXT function to convert the currency to text format and also to concatenate the text. The formula is as follows:
TEXT(Price__c + Shipping_Price__c) & ' USD'Here:
- Firstly, we calculate the sum of the two fields, product price and shipping price.
- Next, we pass the sum to the TEXT function to convert the result of the addition to text.
- After that, we use the & operator to combine the text result with the text “USD”.
- To validate the formula and make sure there are no mistakes, click the “Check Syntax” option.
- Optionally, we may define the “Description,” “Help text,” and “Handle the empty field” if we like.
- Click on the “Next” button to go to the security setup for the formula field.

- In this step, establish “Field-Level Security“. Choose the profiles to which we wish to grant field-level security edit access to this field. If field-level security is not added, the field will be hidden from all profiles.
- As I want it to be visible to all profiles, I have checked the “Visible” checkbox in this instance. After that, click the “Next” button located at the top.

- Add the custom field to the “Page Layout“ after setting up the field-level security. Pick the page layout that has this field in it. If we do not select a layout, the field will not appear on any pages.
- To save the formula field, click the “Save” button.

We can use the formula field once we have created it. Let’s look at an example:
- Open the Products Tab and create a new product with the fields Price and Shipping Price.
- The Total Product Price field, which displays the output of the TEXT() function, then appears when you click on the Details Section.

As a result, we now understand how to use the TEXT function in Salesforce.
Conclusion
We have learned the TEXT() function in Salesforce. Moreover, we have learned the TEXT() function in Salesforce syntax and several real-world business scenarios. In addition, we also covered the steps for using the TEXT() Function in Salesforce.
You may like to read:
- TRUNC() Function in Salesforce
- ATAN2() Function in Salesforce
- Salesforce Case Sensitivity For Text Field Type
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.