Salesforce CURRENCYRATE Function

The Salesforce CURRENCYRATE Function returns the conversion rate to the corporate currency for a given currency Iso Code in the Salesforce platform.

As a Salesforce Administrator, I get this question from most of the Salesforce admin learners.

If you look online, you will find different results regarding that CURRECNCYRATE function topic. Unfortunately, none of the articles work with the whole working of the function from beginning to end.

In this Salesforce tutorial, I am going to give you complete information about the CURRENCYRATE function, with its syntax, example, and use case.

Moreover, I will guide you, as a professional administrator, on how to use this function in both Salesforce Lightning and Salesforce Classic Interface and even steps to setup multi-currency in Salesforce.

Salesforce CURRENCYRATE Function

What is the CURRENCYRATE function in Salesforce?

The Salesforce CURRENCYRATE function is one of the advanced functions of Salesforce, which is used to perform advanced manipulation in Salesforce.

It is a function that gives you the exchange rate value of the currency ISO code that you specified in the multi-currency setup of your Salesforce org. But if you provide the invalid currency ISO code, it always returns 1.0.

Additionally, it is important to keep in mind that the function is returning the currency rate that you define in the manage currency rates tab; it is not returning currency based on dated exchange rates.

How should I write CURRENCYRATE function in Salesforce?

The syntax of the CURRENCYRATE function is as given below:

CURRENCYRATE(IsoCode)

Here:

IsoCode: The IsoCode parameter specifies the currency code in the ISO format. Make sure that you always keep the IsoCode in the quotes as it always treats it similar to the Text.

Additionally, the function returns the conversion rate to the corporate currency for the given CurrencyIsoCode, and it is always returned in the “Number” format. So, make sure that you have chosen the “Number” as the formula return data type.

Where do I use the CURRENCYRATE function in Salesforce?

You can use this function when you are dealing with the data of different countries, and you want to manage the sales across countries.

You can also use this function where you need to calculate the amounts in different currencies automatically and display converted amounts.

Example of Salesforce CURRENCYRATE Function

Below given table explains the working and the logic behind the CURRENCYRATE function in Salesforce:

Input ParameterOutput Result
CURRENCYRATE(‘EUR’)1.09
CURRENCYRATE(‘INR’)0.012
CURRENCYRATE(‘JPY’)0.0068

Here, the “Input” column represents the IsoCode passed as the parameter in the function by the user, and the “Output” column represents the result returned by the CURRENCYRATE function in Salesforce.

How to Enable Multi-Currency in Salesforce

To work with the CURRENCYRATE function in Salesforce, it is mandatory to enable the multi-currency in Salesforce. Here, we have a detailed article on How to Enable Currencies in Salesforce | How to Enable Multiple Currencies in Salesforce

Visit this article and do the multi-currency setup first in Salesforce.

If I do not enable multi-currency in Salesforce, should I still work with the CURRENCYRATE function?

No, you will not work with the CURRENCYRATE function if you don’t enable multiple currency setup in Salesforce.

In the Multi-Currency setup you need to define all the currencies used by your organization. Here, you need to define the conversion rate as per your corporate currency rate.

See also  BEGINS() Function in Salesforce

For example, if the corporate currency is USD, then the conversion rate for the EUR is 1.09 because 1 USD = 1.09 EUR.

Additionally, if you do not enable multi-currency in Salesforce, the CURRENCYRATE function always returns 1.0 and treats all the IsoCode as invalid currency.

How I can use CURRENCYRATE Function in Salesforce Lightning

The following are the steps to use CURRENCYRATE function in Salesforce Lightning.

Let’s understand it with an example: Suppose you want to convert the product price to Indian currency value and show it.

Step-1: Login into the Salesforce account in the Lightning Interface as an administrator and redirect yourself to the “Home Setup” page.

Once reached, click on the “Object Manager” option on the top bar of the page, next to the Home Tab.

Step-2: Search for the object on the “Quick Find Search” box on which you want to use the CURRENCYRATE function and click on it.

According to your scenario, search for the “Product” object.

Salesforce CURRENCYRATE Function

Step-3: On the left side of the page, click on the option “Field & Relationship”. After this, click on the “New” button at the top of the page.

Salesforce CURRENCYRATE Function Example

Step-4: In this step, you will see the list of various data types, choose one from them as you require. As you are going to use the CURRENCYRATE function, for that, you need the data type.

As per the scenario, you need to select the “Formula” field type. To move to the next step, click on the “Next” button.

Salesforce Lightning CURRENCYRATE Function

Step-5: Here, first enter the information by filling in the “Field Label” and “Field Name”.

According to the example, enter “Price in INR” as the field label, and then click on the “Field Name” which automatically filled up.

Now, scroll down and choose the data type for the field in which you want to get the result.

According to the example, you need the result in the Number data type, So check the radio button next to the “Number” data type.

Moreover, you can set the “Decimal Place” to, if you want; by default, it is set to 2. To move to the next step, click on the “Next” button.

Salesforce Lightning CURRENCYRATE Function Example

Step-6: In this step, create your formula in the advanced formula editor tab by taking up the functions from the “All Function Categories”, fields from the “Select Fields”, and operators from the “Operator” dropdown.

According to the scenario, you want to determine the product price in Indian currency and display it. The formula is as follows:

Price__c * CURRENCYRATE('INR') 

Here is a detailed explanation of the formula:

  • Price: It is the field that represents the original price of the product in the corporate currency ‘USD’.
  • CURRENCYRATE(‘INR’): The CURRENCYRATE() function fetches the conversion rate between the corporate currency and Indian Rupees. It converts one unit of the corporate currency to its equivalent in INR.

Then, to ensure there is no error in the above-written formula, click on the “Check Syntax” button.

Optionally, you can define the “Description” and “Help Text” as well, as if you want, you can “Handle the empty field”.

To proceed to the next step, click on the “Next” button.

CURRENCYRATE Function in Salesforce

Step-7: In this step, you have to set up the “Field-Level Security”. You have to choose the profile to whom you want to grant field-level security edit access to this field.

If field-level security is not chosen, the field will be hidden from all profiles. After that, click on the “Next” button to move.

CURRENCYRATE Function in Salesforce Example

Step-8: You have to add the custom field to the “Page Layouts”. For this, pick the page layout on which this field is visible.

See also  Salesforce ISNUMBER Function

If you do not choose any page layout, the field will not appear on any pages. Finally, click the “Save” button to save the formula field.

CURRENCYRATE Function in Salesforce Lightning

Step-9: You can use the formula field once you have created it. Let’s look at it:

  • Open the “Products” item, create a new product with the “Price” field and save it.
  • Move to the “Details” section. Here, you will find the “Price in INR” field that shows you the result of the function.

Let’s deeply understand it with an example:

  • Suppose you have created a product with the price “$500”. Now, once you execute the function, the CURRENCYRATE function gets activated, pick the INR exchange rate from the multi-currency setup, and convert it.
  • The final result price in INR is now calculated and shown as “41565.00” rupees.
CURRENCYRATE Function in Salesforce Lightning Example

With this, you have learned to use the CURRENCYRATE function in Salesforce Lightning. Now, you will explore the use of the CURRENCYRATE function in Salesforce Classic.

How to use CURRENCYRATE Function in Salesforce Classic

Let’s consider a scenario where you want to convert the transaction amount to the IsoCode provided based on the transaction type of the order.

Follow the below-given steps to fulfill your above scenario requirement and learn to use the CURRENCYRATE function in Salesforce Classic in the formula field.

Step-1: Login to your Salesforce account as an administrator and redirect yourself to the Classic Interface of Salesforce. Then, click on the “Setup” option located at the top side of the page next to the Help option.

Step-2: Now use the “Quick Find” search box and search for the object on which you want to use the CURRENCYRATE function and click on it.

After that, click on the “Fields” option from the dropdown option list of the object.

According to the scenario, you need to search for the “Orders” object.

Salesforce Classic CURRENCYRATE Function

Step-3:  The orders field page is opened after clicking on the fields option. Now move to the button of the page in the section “Order Custom Fields & Relationship” and click on the “New” button to start the process of creating a new field.

Salesforce Classic CURRENCYRATE Function Example

Step-4: Choose the data type as per the information you want to store. According to the scenario, you need to select the “Formula” data type.

To move to the next step, click on the “Next” button.

CURRENCYRATE Function in Salesforce Classic

Step-5: In this step, enter the “Field Label”, and when you click on the “Field Name”, the field name will automatically fill up. You can enter the field label as “Final EUR Price After Discount”.

Scroll down to the “Formula Return Type” section and choose the return data type for the newly created field. According to the scenario, you need to choose the “Number” as the data type.

After that, click on the “Next” button to proceed.

CURRENCYRATE Function in Salesforce Classic Example

Step-6: Now, create the formula. First, move to the right side of the page, click on “All Function Categories“, then click on “Advanced”.

Once you click on the advanced category, you will get the list of the functions; now select the “CURRENCYRATE” function, and after that, click on the “Insert Selected Function”.

Similarly, you can insert more functions if you need, and you can add the fields and operators from the “Insert Field” and “Insert Operator” buttons, respectively.

See also  Salesforce FormatDuration Function

According to the scenario, you want to determine how to convert the transaction amount based on the transaction type to the currency given in IsoCode.

The formula is as follows:

CASE(
   Order_Type__c,
   'Regular', Price__c * CURRENCYRATE('EUR'),
   'Promotion', Price__c * CURRENCYRATE('EUR') * 0.90,
   'Special Offer', Price__c * CURRENCYRATE('EUR') * 0.85,
   Price__c
)

Here is the detailed description of the formula:

  • Order Type: It is the field that represents the type of order, such as ‘Regular,’ ‘Promotion,’ or ‘Special Offer.’
  • CASE() function: The CASE function works as per the order type as given below:
    • If the order type is ‘Regular’, the formula calculates the price by converting it to Euros using the CURRENCYRATE function.
    • If the order type is ‘Promotion’, the formula calculates the price by converting it to Euros and applying a 10% discount.
    • If the order type is ‘Special Offer’, the formula calculates the price by converting it to Euros and applying a 15% discount.
    • If the order type does not match any of the specified cases, the formula returns the original price without any conversion.

Next, click on the “Check Syntax” button to validate the formula and ensure no errors. And if you want, you can define the “Description”, and “Help Text” as well as “Handle the empty field”.

To proceed to the next step, click on the “Next” button.

How to use CURRENCYRATE Function in Salesforce

Step-7: In this step, establish the “Field-Level Security”. Here, you can set the visibility of a profile for the field by checking the checkbox in the “Visible” column.

Also, you can adjust the “Read-Only” access for each profile based on our requirements by checking the checkbox in the “Read Only” column.

Click on the “Next” button to move to the next step.

How to use CURRENCYRATE Function in Salesforce Example

Step-7: Now, choose the page layout on which you want to include this field. The field won’t show up on any page if you have not chosen the layout.

Then, click on the “Save” button to complete the process.

How to use CURRENCYRATE Function in Salesforce Classic

Step-8: Let’s check how the formula is working:

Open the “Orders” object, create a new order with the “Order Type” and “Price” and save it

On the “Details” section of the page, you will get the “Final EUR Price After Discount” field that shows you the result of the CURRENCYRATE function.

Let’s see an example:

Suppose you have created an order with a price of ‘$1000’, order type ‘Promotion’, and IsoCode you passed ‘EUR’ and save it. Now, when the formula is executed, it gives you results as ‘828′ ($1000 * 0.92 *0.90 = 828).

Example of Salesforce CURRENCYRATE Function

With this, you have learned how to use the CURRENCYRATE function in Salesforce Classic with example

Conclusion

I hope that the information about the CURRENCYRATE Salesforce function provides you with a clearer picture of what the CURRENCYRATE function is, its syntax, use case, and example.

Additionally, you will become confident in how to use the CURRENCYRATE function in Salesforce Lightning and Salesforce Classic in the formula field as per your needs.

You may like to read: