Creating Formula Fields | Online Help - Zoho CRM

Creating Formula Fields

Formula fields are used to calculate different types of values, including numeric values, text values, date values, etc. Formula fields and their resulting return value have certain data types associated with them and there are specific operators that can be used for each data type. It is necessary to understand the type of fields required for creating formula fields and the compatibility between the data types and the operators. For instance, the operator " * " (for multiplication) is used on numeric values and not on text values.

  • You cannot modify the Return type for the formula fields.
  • Maximum 5000 characters can be used in the formula expression.
Availability
Permission Required
Users with the Field-level Access permission in profile can access this feature.

Create Numeric Formula Field

The following table helps you to understand the type of arguments required for numeric functions along with the type of syntax that needs to be formed.

Function

Description

Usage

Examples

Abs

Returns the absolute value of the Number.

Abs(number)

Abs(-42) returns 42; Abs(+33) returns 33

Ceil

Returns the smallest digit greater than or equal to the input number.

Ceil(number)

Ceil(3.4) returns 4; Ceil(-3.4) returns -3

Floor

Returns the largest digit less than or equal to the input number.

Floor(number)

Floor(3.8) returns 3; Floor(-3.4) returns -4

Naturallog

Returns the natural logarithm of a number

Naturallog(number)

Naturallog(1) returns 0.69

Base10log

Returns the base 10 logarithm of the input number

Base10log(number)

Base10log(10) returns 1.0

Max

Returns the maximum value from the specified list of compatible data types.

Max(value1, value2,...)

Max(3,1,5,2) returns 5; Max(0,-4,-3,2) returns 2

Min

Returns the minimum value from the specified list of compatible data types.

Min(value1, value2,...)

Min(5,-3,0,1) returns -3; Min(5,0,.01,0.5) returns 0.0

Sqrt

Returns the square root of the input number.

Sqrt(number)

Sqrt(4) returns 2; Sqrt(9) returns 3

FromTimestamp

Creates date time from timestamp

FromTimestamp(number)

FromTimestamp(1581066895) gives result as Feb 7, 2020 02:44 PM

Note: The above example is for the IST timezone. The values will changed based on the timezone of the user.

IsPositive

Checks if the number is positive

IsPositive(number)

IsPositive(-345) gives result as false

IsNegative

Checks if the number is negative

IsNegative(number)

IsNegative(-345) gives result as true

Round

Rounds the number to the nearest value based on the specified precision.

Round(number); Round(number,number)

Round(3.8) gives result as 4 ; Round(-3.5) gives result as -3 ; Round(3.417,2) gives result as 3.42

To create numeric type formula fields

  1. Log in to Zoho CRM with Administrator privileges.
  2. Go to Setup > Customization > Modules and Fields.
    Module refers to the Leads, Accounts, Contacts, etc. tabs.
  3. Click the required module.
    The Layout Editor opens.
  4. Drag and drop the Formula field from the New Fields tray to the required module section on the right.
  5. In the  Formula Properties window, do the following:
    • Enter id in the Field Label field..
    • Select Number/Currency as the Formula Return Type from the drop-down list.
      In the case of Number and Currency Return Type fields, enter a value for Decimal places.
    Constructing Formulas
  6. Under Select Functions, select Numeric Functions from the drop-down list.
  7. From the list of Numeric Functions, choose a function and click Insert.
    (Alternatively, you can double-click on a function to insert)
  8. In the Formula expression, click between the parenthesis to insert an argument.
  9. Under Select Field column, choose a field and click Insert.
    (Alternatively, you can double-click on a field to insert)
  10. Under Select Operator column, choose an operator and click Insert.
  11. Click Check Syntax to check the construction of the formula.
  12. Click Save.

Create String Formula Field

The following table helps you to understand the type of arguments required for formula functions along with the type of syntax that needs to be formed.

FunctionDescriptionUsage
Examples 

LenReturns the number of characters in a specified text string.Len(string)Len('abc') returns 3; Len(' abc ') returns 5
FindReturns the nth occurrence of the text string.Find('string','search string',number)Find('greenery','n',1) returns 5
ConcatReturns the concatenation of all the strings.Concat('string','string',...)Concat('FirstName',' ','LastName') returns FirstName LastName
ContainsReturns true if search string is found in the other string, otherwise returns false.Contains('string','search string')Contains('abcdef','cd') returns true
StartswithReturns true if the string begins with the search string, otherwise returns false.Startswith('string','search string')Startswith('abcdef','cd') returns false
Startswith('abcdef','abc') returns true
EndswithReturns true if the string ends with the search string, otherwise returns false.Endswith('string','search string')Endswith('abcdef','ab') returns false
Endswith('abcdef','ef') returns true
LowerConverts all characters in a string to lower case.Lower('string')Lower('APPLES') returns "apples"
Lower('Apples') returns "apples"
UpperConverts all characters in a string to upper case.Upper('string')Upper('apples') returns "APPLES"
Upper('APPles') returns "APPLES"
TrimReturns string with the leading and trailing white space characters removed.Trim('string')Trim(' abcd ') returns "abcd"
SubstringReturns a portion of an input string, from a start position in the string to the specified length.Substring('string',n1,n2)Substring('abcdefg',4,7) returns "defg"
ReplaceReplaces each occurrence of the search string in the input string with the corresponding replace string.Replace('string','search string','replace string')Replace('abcdefg','abc','xyz') returns "xyzdefg"
TostringConverts any argument to a string data type.Tostring(generic argument)Tostring(3.4) returns "3.4"
Tostring('') returns < empty >

CaseInsensitiveEquals 

Compares two strings in case insensitive manner.

CaseInsensitiveEquals(string,string)

CaseInsensitiveEquals('asdf','AsDf') gives result as true; CaseInsensitiveEquals('asdf','AsDg')gives result as false

IsEmpty

Checks whether the value is empty or not.

IsEmpty(generic)

IsEmpty('') gives result as true; IsEmpty('asdf') gives result as false; IsEmpty(${Customer.Score}) gives result as true if Score is not entered.

DateBetween

Returns the time between two dates where the unit can be years, months, weeks, days, hours,  minutes.

DateBetween(date-time,date-time,string)

DateBetween(Newdate(2022,02,10,11,30,'AM'), Newdate(2023,02,19,11,30,'AM'),'years') gives result as 1

Note
  1. The string constants should always be enclosed in single quotes(')
  2. Field labels do not need to be enclosed in single quotes (').
  3. Values of the String data type can be used with == and != operations inside If(), Or(), And(), and Not() library functions.
    For example, If ('abc' == 'abc', ${returnValue1}, ${returnvalue2})

To create String type formula fields

  1. Log in to Zoho CRM with Administrator privileges.
  2. Go to Setup > Customization > Modules and Fields.
    Module refers to the Leads, Accounts, Contacts, etc. tabs.
  3. Click the required module.
    The Layout Editor opens.
  4. Drag and drop the Formula field from the New Fields tray to the required module section on the right.
  5. In the  Formula Properties window, do the following:
    • Enter id in the Label field.
    • Select String as theFormula Return Type from the drop-down list.
    Constructing Formulas
  6. Under Select Functions, select String Functions from the drop-down list.
  7. From the list of String Functions, choose a function and click Insert.
    (Alternatively, you can double-click on a function to insert)
  8. In the Formula expression, click between the parenthesis to insert an argument.
  9. Under Select Field column, choose a field and click Insert.
    (Alternatively, you can double-click on a field to insert)
  10. Under Select Operator column, choose an operator and click Insert.
  11. Click Check Syntax to check the construction of the formula.
  12. Click Save.

Create DateTime Formula Field

The following table helps you to understand the type of arguments required for DateTime functions along with the type of syntax that needs to be formed.

FunctionDescriptionUsageExamples
NewdateCreates a date from the year, month, day and time.Newdate(year,month,day, hour,minute,'string')Newdate(2007,12,21,06,30,'AM') returns quot;21/12/2007 06:30 AM"1
DatepartReturns the date value for the date time expression.Datepart(datetime argument)Datepart(Newdate(2007,12,21,06,30,'AM')) returns "21/12/2007"1
TimepartReturns the time value for the date time expression.Timepart(datetime argument)Timepart(Newdate(2007,12,21,06,30,'AM')) returns "06.30 AM"
AdddateReturns the date obtained by adding n (year/day/month/hour/min) to the given date.Adddate(datetime,number, 'string')Adddate(Newdate(2007,12,21,06,30,'AM'),2,'YEAR' returns "21/12/2009 06:30 AM"2
SubdateReturns the date obtained by subtracting n (year/day/month/hour/min) to the given date.Subdate(datetime,number, 'string')Subdate (Newdate(2007,12,21,06,30,'AM'),2,'YEAR' returns "21/12/2005 06:30 AM"2
NowReturns a date/time representing the current moment.Now()Now() returns "19/05/2009 10:52 AM"
DatecompCompares two dates and returns the difference of days in minutes.Datecomp(Datetime, Datetime)Datecomp(Newdate(2009,05,19,11,30,'AM'), Newdate(2009,05,19,12,30,'AM')) returns 660.0 3
DayofmonthReturns the day of the month for the given date.Dayofmonth(Datetime)Dayofmonth(Newdate(2009,05,19,11,30,'AM')) returns "19.0"
HourReturns the hour corresponding to the given date.Hour(Datetime)Hour(Newdate(2009,05,19,11,30,'AM')) returns "11.0"
MinuteReturns the minute corresponding to the given date.Minute(Datetime)Minute(Newdate(2009,05,19,11,30,'AM')) returns "30.0"
MonthReturns the month corresponding to the given date.Month(Datetime)Month(Newdate(2009,05,19,11,30,'AM')) returns "5.0"
YearReturns the year corresponding to the given dateYear(Datetime)Year(Newdate(2009,05,19,11,30,'AM')) returns "2009.0"
WeekdayReturns the day of the week (1-7) corresponding to the input date, where 1 is Sunday, 2 is Monday and so on.Weekday(Datetime)Weekday(Newdate(2009,05,19,11,30,'AM')) returns "3.0". (This is because 19th May is Tuesday)4

Dayofweek

Returns the day of the week for the given date.

Dayofweek(date-time)

April 5th 2023 returns "wednesday"

Dayofmonth

Returns the number corresponding to the day of the month for the given date.

Dayofmonth(date-time)

April 5th returns '5'

Dayofyear

Returns the number corresponding to day of the year for the given date.

Dayofyear(date-time)

April 5th 2023 returns "95"

Timestamp

Returns timestamp of the value

Timestamp(date-time)

Timestamp(Newdate(2022,02,10,11,30,'AM')) gives result as 1,171,107,000

Note: The above example is for the IST timezone. The values will changed based on the timezone of the user.

  1. The input DateTime argument format should always be YYYY,MM,DD,HH,MM,AM/PM but the output will be displayed as per the selected Country Locale.
  2. The string data type (YEAR/DAY/MONTH/HOUR/MINUTE) should be in UPPERCASE.
  3. The resulting return value for the Datecomp function is always displayed in minutes.
  4. If the date value is "0" the function returns null.

To create date time type formula fields

  1. Log in to Zoho CRM with Administrator privileges.
  2. Go to Setup > Customization > Modules and Fields.
    Module refers to the Leads, Accounts, Contacts, etc. tabs.
  3. Click the required module.
    The Layout Editor opens.
  4. Drag and drop the Formula field from the New Fields tray to the required module section on the right.
  5. In the  Formula Properties window, do the following:
    • Enter id in the Label field.
    • Select DateTime as the Formula Return Type from the drop-down list.
    Constructing Formulas
  6. Under Select Functions, select DateTime Functions from the drop-down list.
  7. From the list of DateTime Functions, choose a function and click Insert.
    (Alternatively, you can double-click on a function to insert)
  8. In the Formula expression, click between the parenthesis to insert an argument.
  9. Under Select Field column, choose a field and click Insert.
    (Alternatively, you can double-click on a field to insert)
  10. Under Select Operator column, choose an operator and click Insert.
  11. Click Check Syntax to check the construction of the formula.
  12. Click Save.

Create Boolean Formula Field

The following table helps you to understand the type of arguments required for boolean functions along with the type of syntax that needs to be formed.

FunctionDescriptionUsageExamples
IfReturns one of two values, depending on the value of a given logical condition. If the boolean test is true, If() returns the true value, otherwise returns the false value.If(Boolean,Generic, Generic)*If(8>7,1,0) returns "1.0"
If(8>7,'True','False') returns "True"
AndReturns a true response if all expressions are true; returns a false value even if one of the expressions is false.And(boolean,boolean ...)And(2>1,5>3,7<8) returns "true"
And(2>1,5>3,7>8) returns "false"
OrReturns true if any one expression is true. Returns false if all expressions are false.Or(boolean,...)Or(2>1,3>5,7>8) returns "true"
Or(1>2,3>5,7>8) returns "false"
NotReturns the logical negation of the given expression(If the expression is true, returns false).Not(boolean)Not(false) returns "true"
Not(true) returns "false"

* Generic implies any data type - Number, String, Datetime (including normal date) or Boolean. The return type depends on the selected data type. For instance, if the generic data type is a number, the return type should be Numeric and not string or boolean.

*Values of the String data type can be used with == and != operations inside If(), Or(), And(), and Not() library functions. For example, If ('abc' == 'abc', ${returnValue1}, ${returnvalue2})*

To create boolean type formula fields

  1. Log in to Zoho CRM with Administrator privileges.
  2. Go to Setup > Customization > Modules and Fields.
    Module refers to the Leads, Accounts, Contacts, etc. tabs.
  3. Click the required module.
    The Layout Editor opens.
  4. Drag and drop the Formula field from the New Fields tray to the required module section on the right.
  5. In the  Formula Propertieswindow, do the following:
    • Enter id in the Label field.
    • Select Boolean Functions as the Formula Return Type from the drop-down list.
    Constructing Formula
  6. Under Select Functions, select Boolean Functions from the drop-down list.
  7. From the list of Boolean Functions, choose a function and click Insert.
    (Alternatively, you can double-click on a function to insert)
  8. In the Formula expression, click between the parenthesis to insert an argument.
  9. Under Select Field column, choose a field and click Insert.
    (Alternatively, you can double-click on a field to insert)
  10. Under Select Operator column, choose an operator and click Insert.
  11. Click Check Syntax to check the construction of the formula.
  12. Click Save.

Formula Syntax Reference

The following table displays the functional reference for creating formulae along with their available arguments.

Numeric Functions

Function NameNo. of Required ArgumentsArgument Data TypeReturn Type
Abs1NumberNumber
Ceil1Numbernumber
Floor1NumberNumber
Naturallog1NumberNumber
Base10log1NumberNumber
MaxMultipleAll NumberNumber
MinMultipleAll NumberNumber
Sqrt1NumberNumber

String Functions

Function NameNo. of Required ArgumentsArgument Data Type>Return Type
Len1StringNumber
Find3String: String: NumberNumber
ConcatMultipleAll StringString
Contains2String: StringBoolean
Startswith2String: StringBoolean
Endswith2String: StringBoolean
Lower1StringString
Upper1StringString
Trim1StringString
Substring3String: Number: NumberString
Replace3String: String: StringString
Tostring1Any data typeString

DateTime Functions

Function NameNo. of Required ArgumentsArgument Data TypeReturn Type
Newdate6Number:Number:Number:Number:Number:StringDatetime
Datepart1DatetimeString
Timepart1DatetimeString
Adddate3Datetime: Number: StringDatetime
Subdate3Datetime: Number: StringDatetime
Now0-Datetime
Datecomp2Datetime: DatetimeNumber
Dayofmonth1DatetimeNumber
Hour1DatetimeNumber
Minute1DatetimeNumber
Month1DatetimeNumber
Year1DatetimeNumber
Weekday1DatetimeNumber

Boolean Functions

Function NameNo. of Required ArgumentsArgument Data TypeReturn Type
If3Boolean: Generic: GenericGeneric
AndMultipleAll BooleanBoolean
OrMultipleAll BooleanBoolean
Not1BooleanBoolean


Note
  1. String constants should be enclosed within single quotes.
  2. Generic implies any data type - Number, String, Datetime (including normal date) or Boolean.

Blank value computation

Note: This option is being released in a phased manner. It will soon be released to all users.

When you create a formula field, you can decide how blank values in participating fields are to be interpreted.
This is available under Blank value preference and you can pick one of the following options:
  1. Consider blank values as empty.
  2. Consider blank values as 0 for integers and decimals, "(empty)  for strings.
The first option 'Consider blank values as empty' will be selected by default when you create a new formula field.

Consider the following example:
  1. Rent is the formula field.
  2. The formula used is: Number of units * Price of a unit * Period of storage required.
  3. Number of units, Price of a unit, and Period of storage are all participating fields.
  4. Period of storage is blank.
a) If Consider blank values as empty is chosen for the Rent field:
Period of storage is interpreted as empty, and the formula will not compute the result. So, Rent will remain blank or empty.

b) If Consider blank value as 0 for integers and decimals, '' for strings is chosen for the Rent field:
Period of storage is interpreted as 0, and the formula will compute the result based on this value.




    Zoho CRM Training Programs

    Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

    Zoho CRM Training
      Redefine the way you work
      with Zoho Workplace

        Zoho DataPrep Personalized Demo

        If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

        Zoho CRM Training

          Create, share, and deliver

          beautiful slides from anywhere.

          Get Started Now


            Zoho Sign now offers specialized one-on-one training for both administrators and developers.

            BOOK A SESSION








                                    You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                        Manage your brands on social media

                                          Zoho Desk Resources

                                          • Desk Community Learning Series


                                          • Digest


                                          • Functions


                                          • Meetups


                                          • Kbase


                                          • Resources


                                          • Glossary


                                          • Desk Marketplace


                                          • MVP Corner


                                          • Word of the Day


                                            Zoho Marketing Automation

                                              Zoho Sheet Resources

                                               

                                                  Zoho Forms Resources


                                                    Secure your business
                                                    communication with Zoho Mail


                                                    Mail on the move with
                                                    Zoho Mail mobile application

                                                      Stay on top of your schedule
                                                      at all times


                                                      Carry your calendar with you
                                                      Anytime, anywhere




                                                            Zoho Sign Resources

                                                              Sign, Paperless!

                                                              Sign and send business documents on the go!

                                                              Get Started Now




                                                                      Zoho TeamInbox Resources



                                                                              Zoho DataPrep Resources



                                                                                Zoho DataPrep Demo

                                                                                Get a personalized demo or POC

                                                                                REGISTER NOW


                                                                                  Design. Discuss. Deliver.

                                                                                  Create visually engaging stories with Zoho Show.

                                                                                  Get Started Now









                                                                                                      • Related Articles

                                                                                                      • Building Formula Fields

                                                                                                        The Zoho CRM formula fields enable you to define fields that can populate dynamically calculated data based on the values returned from other standard or custom fields. For instance, an insurance company may need to determine, if the provided date of ...
                                                                                                      • Working with Custom Fields

                                                                                                        In Zoho CRM, you can add new fields as per your requirements. These fields will be available to all the users added to your organization's CRM account. Customize Zoho Defined Fields: You can edit, delete and hide some of Zoho defined fields, but note ...
                                                                                                      • Types of Custom Fields

                                                                                                        In Zoho CRM, you can add different types of custom fields as per your requirements. These fields will be available to all the users added to your organization's CRM account. Customize Zoho Defined Fields : You can edit, delete and hide some of Zoho ...
                                                                                                      • Examples of Formula Field

                                                                                                        Formula Fields can be complicated sometimes. So, here are examples that will help you understand the usage of these types of fields in Zoho CRM. IF ELSE Statement Example: If field name contains 'Golf Only 1 Meal', then return 265 ; Else if field ...
                                                                                                      • Data types in Formula Fields

                                                                                                        Data type is the kind of data that can be held and stored while evaluating an expression. Data types are the defined set of values and the allowable operations on those values. They represent either the function, argument, return value or the ...
                                                                                                        Wherever you are is as good as
                                                                                                        your workplace

                                                                                                          Resources

                                                                                                          Videos

                                                                                                          Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                          eBooks

                                                                                                          Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                          Webinars

                                                                                                          Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                          CRM Tips

                                                                                                          Make the most of Zoho CRM with these useful tips.



                                                                                                            Zoho Show Resources