About calculation operators
Operators specify the type of calculation that you want to perform on the elements of a formula. Lists support three different types of calculation operators: arithmetic, comparison, and text.
Types of operators
Arithmetic operators To perform basic mathematical operations such as addition, subtraction, or multiplication; combine numbers; and produce numeric results, use the following arithmetic operators.
Arithmetic operator Meaning (Example)
+ (plus sign) Addition (3+3)
– (minus sign) Subtraction (3–1)
Negation (–1)
* (asterisk) Multiplication (3*3)
/ (forward slash) Division (3/3)
% (percent sign) Percent (20%)
^ (caret) Exponentiation (3^2)
Comparison operators You can compare two values with the following operators. When two values are compared by using these operators, the result is a logical value of Yes or No.
Comparison operator Meaning (Example)
= (equal sign) Equal to (A=B)
> (greater than sign) Greater than (A>B)
< (less than sign) Less than (A<B)
>= (greater than or equal to sign) Greater than or equal to (A>=B)
<= (less than or equal to sign) Less than or equal to (A<=B)
<> (not equal to sign) Not equal to (A<>B)
Text concatenation operator Use the ampersand (&) to join, or concatenate, one or more text strings to produce a single piece of text.
Text operator Meaning (Example)
& (ampersand) Connects, or concatenates, two values to produce one continuous text value ("North"&"wind")
The order in which a list performs operations in a formula
Formulas calculate values in a specific order. A list formula might begin with an equal sign (=). Following the equal sign are the elements to be calculated (the operands), which are separated by calculation operators. Lists calculate the formula from left to right, according to a specific order for each operator in the formula.
Operator precedence
If you combine several operators in a single formula, lists perform the operations in the order shown in the following table. If a formula contains operators with the same precedence — for example, if a formula contains both a multiplication and division operator — lists evaluate the operators from left to right.
Operator Description
– Negation (as in –1)
% Percent
^ Exponentiation
* and / Multiplication and division
+ and – Addition and subtraction
& Connects two strings of text (concatenation)
= < > <= >= <> Comparison
Use of parentheses
To change the order of evaluation, enclose in parentheses the part of the formula to be calculated first. For example, the following formula produces 11 because a list calculates multiplication before addition. The formula multiplies 2 by 3 and then adds 5 to the result.
=5+2*3
In contrast, if you use parentheses to change the syntax, the list adds 5 and 2 together and then multiplies the result by 3 to produce 21.
=(5+2)*3
In the example below, the parentheses around the first part of the formula force the list to calculate [Cost]+25 first and then divide the result by the sum of the values in columns EC1 and EC2.
=([Cost]+25)/SUM([EC1]+[EC2])
About constants in formulas
A constant is a value that is not calculated. For example, the date 10/9/2008, the number 210, and the text "Quarterly Earnings" are all constants. Constants can be of the following data types:
String (Example: =[Last Name] = "Smith")
String constants are enclosed in double quotes and can be up to 255 characters.
Number (Example: =[Cost] >= 29.99)
Numeric constants can include decimal places, and can be positive or negative.
Date (Example: =[Date] <> 7/7/2002)
Date constants do not require delimiters.
Boolean (Example: =IF([Cost]>[Revenue], "Loss", "No Loss")
Yes and No are Boolean constants. You can use them in conditional expressions. In the above example, if Cost is greater than Revenue, the IF function returns Yes, and the formula returns the string "Loss". If Cost is equal to or less than Revenue, the function returns No, and formula returns the string "No Loss".
Examples of common formulas
Note You can use the following examples in calculated columns. Examples that do not include column references can be used to specify the default value of a column.
Conditional formulas
Check if a number is greater than or less than another number
Use the IF function to do this task.
Column1 Column2 Formula Description
15000 9000 =Column1>Column2 Is Column1 greater than Column2? (Yes)
15000 9000 =IF(Column1<=Column2, "OK", "Not OK") Is Column1 less than or equal to Column2? (Not OK)
Return a logical value after comparing column contents
For a result that is a logical value (Yes or No), use the AND, OR, and NOT functions.
Column1 Column2 Column3 Formula Description
15 9 8 =AND(Column1>Column2, Column1<Column3) Is 15 greater than 9 and less than 8? (No)
15 9 8 =OR(Column1>Column2, Column1<Column3) Is 15 greater than 9 or less than 8? (Yes)
15 9 8 =NOT(Column1+Column2=24) Is 15 plus 9 not equal to 24? (No)
For a result that is another calculation, or any other value other than Yes or No, use the IF, AND, and OR functions.
Column1 Column2 Column3 Formula Description
15 9 8 =IF(Column1=15, "OK", "Not OK") If the value in Column1 equals 15, then return "OK". (OK)
15 9 8 =IF(AND(Column1>Column2, Column1<Column3), "OK", "Not OK") If 15 is greater than 9 and less than 8, then return "OK". (Not OK)
15 9 8 =IF(OR(Column1>Column2, Column1<Column3), "OK", "Not OK") If 15 is greater than 9 or less than 8, then return "OK". (OK)
Display zeroes as blanks or dashes
Use the IF function to do this task.
Column1 Column2 Formula Description
10 10 =Column1-Column2 Second number subtracted from the first (0)
10 10 =IF(Column1-Column2,"",Column1-Column2) Returns null when the value is zero (blank column)
15 9 =IF(Column1-Column2,"-",Column1-Column2) Returns a dash when the value is zero (-)
Date and time formulas
Add dates
To add a number of days to a date, use the addition (+) operator. Note that when manipulating dates, the return type of the calculated column must be set to Date and Time.
Column1 Column2 Formula Description
6/9/2007 3 =Column1+Column2 Add 3 days to 6/9/2007 (6/12/2007)
12/10/2008 54 =Column1+Column2 Add 54 days to 12/10/2008 (2/2/2009)
To add a number of months to a date, use the DATE, YEAR, MONTH, and DAY functions.
Column1 Column2 Formula Description
6/9/2007 3 =DATE(YEAR(Column1),MONTH(Column1)+Column2,DAY(Column1)) Add 3 months to 6/9/2007 (9/9/2007)
12/10/2008 25 =DATE(YEAR(Column1),MONTH(Column1)+Column2,DAY(Column1)) Add 25 months to 12/10/2008 (1/10/2011)
To add a number of years to a date, use the DATE, YEAR, MONTH, and DAY functions.
Column1 Column2 Formula Description
6/9/2007 3 =DATE(YEAR(Column1)+Column2,MONTH(Column1),DAY(Column1)) Add 3 years to 6/9/2007 (6/9/2010)
12/10/2008 25 =DATE(YEAR(Column1)+Column2,MONTH(Column1),DAY(Column1)) Add 25 years to 12/10/2008 (12/10/2033)
To add a combination of days, months, and years to a date, use the DATE, YEAR, MONTH, and DAY functions.
Column1 Formula Description
6/9/2007 =DATE(YEAR(Column1)+3,MONTH(Column1)+1,DAY(Column1)+5) Add 3 years, 1 month, and 5 days to 6/9/2007 (7/14/2010)
12/10/2008 =DATE(YEAR(Column1)+1,MONTH(Column1)+7,DAY(Column1)+5) Add 1 year, 7 months, and 5 days to 6/9/2007 (1/14/2009)
Calculate the difference between two dates
Use the DATEDIF function to do this task.
Column1 Column2 Formula Description
01-Jan-1995 15-Jun-1999 =DATEDIF(Column1, Column2,"d") Return the number of days between the two dates (1626)
01-Jan-1995 15-Jun-1999 =DATEDIF(Column1, Column2,"ym") Return the number of months between the dates, ignoring the year part (5)
01-Jan-1995 15-Jun-1999 =DATEDIF(Column1, Column2,"yd") Return the number of days between the dates, ignoring the year part (165)
Calculate the difference between two times
For presenting the result in the standard time format (hours:minutes:seconds), use the subtraction operator (-) and the TEXT function.
For this method to work, hours must not exceed 24, and minutes and seconds must not exceed 60.
Column1 Column2 Formula Description
06/09/2007 10:35 AM 06/09/2007 3:30 PM =TEXT(Column2-Column1,"h") Hours between two times (4)
06/09/2007 10:35 AM 06/09/2007 3:30 PM =TEXT(Column2-Column1,"h:mm") Hours and minutes between two times (4:55)
06/09/2007 10:35 AM 06/09/2007 3:30 PM =TEXT(Column2-Column1,"h:mm:ss") Hours,minutes, and seconds between two times (4:55:00)
For presenting the result in a total based on one time unit, use the INT function, or HOUR, MINUTE, and SECOND functions.
Column1 Column2 Formula Description
06/09/2007 10:35 AM 06/10/2007 3:30 PM =INT((Column2-Column1)*24) Total hours between two times (28)
06/09/2007 10:35 AM 06/10/2007 3:30 PM =INT((Column2-Column1)*1440) Total minutes between two times (1735)
06/09/2007 10:35 AM 06/10/2007 3:30 PM =INT((Column2-Column1)*86400) Total seconds between two times (104100)
06/09/2007 10:35 AM 06/10/2007 3:30 PM =HOUR(Column2-Column1) Hours between two times, when the difference does not exceed 24. (4)
06/09/2007 10:35 AM 06/10/2007 3:30 PM =MINUTE(Column2-Column1) Minutes between two times, when the difference does not exceed 60. (55)
06/09/2007 10:35 AM 06/10/2007 3:30 PM =SECOND(Column2-Column1) Seconds between two times, when the difference does not exceed 60. (0)
Convert times
To convert hours from standard time format to a decimal number, use the INT function.
Column1 Formula Description
10:35 AM =(Column1-INT(Column1))*24 Number of hours since 12:00 AM (10.583333)
12:15 PM =(Column1-INT(Column1))*24 Number of hours since 12:00 AM (12.25)
To convert hours from decimal number to the standard time format (hours:minutes:seconds), use the divisor operator and the TEXT function.
Column1 Formula Description
10:5833 =TEXT(Column1/24, "h:mm") Hours since 12:00 AM (10:35)
12:25 =TEXT(Column1/24, "h:mm") Hours since 12:00 AM (12:15)
Insert Julian dates
The phrase "Julian date" is sometimes used to refer to a date format that is a combination of the current year, and the number of days since the beginning of the year. For example, January 1, 2007 is represented as 2007001 and December 31, 2007 is represented as 2003356.
There is also a Julian date commonly used in astronomy, which is a serial date system starting on January 1, 4713 B.C.E.
Note This format is not based on the Julian calendar.
To convert a date to a Julian date, use the TEXT and DATEVALUE functions.
Column1 Formula Description
6/23/2007 =TEXT(Column1,"yy")&TEXT((Column1-DATEVALUE("1/1/"& TEXT(Column1,"yy"))+1),"000") Date in "Julian" format, with a two-digit year (07174)
6/23/2007 =TEXT(Column1,"yyyy")&TEXT((Column1-DATEVALUE("1/1/"&TEXT(Column1,"yy"))+1),"000") Date in "Julian" format, with a four-digit year (2007174)
To convert a date to a Julian date used in astronomy, use the constant 2415018.50.
This formula only works for dates after 3/1/1901, and if you are using the 1900 date system.
Column1 Formula Description
6/23/2007 =Column1+2415018.50 Date in "Julian" format, used in astronomy (2454274.50)
Show dates as the day of the week
To convert dates to the text for the day of the week, use the TEXT and WEEKDAY functions.
Column1 Formula Description
19-Feb-2007 =TEXT(WEEKDAY(Column1), "dddd") Calculates the day of the week for the date and returns the full name of the day (Monday)
3-Jan-2008 =TEXT(WEEKDAY(Column1), "ddd") Calculates the day of the week for the date and returns the abbreviated name of the day (Thu)
Math formulas
Add numbers