﻿ Calculate data in lists or libraries

# Calculate data in lists or libraries

You can use formulas and functions in lists or libraries to calculate data in a variety of ways. By adding a calculated column to a list or library, you can create a formula that includes data from other columns and performs functions to calculate dates and times, to perform mathematical equations, or to manipulate text. For example, on a tasks list, you can use a column to calculate the number of days it takes to complete each task, based on the Start Date and Date Completed columns.

Note   This topic explains how to work with calculated columns in lists and libraries. Links to additional content about working with specific formulas or functions are included in the See Also section. For detailed information about functions, including syntax and examples of use, see Formulas and functions. For examples of how to use common formulas, see Examples of common formulas.

## Add a calculated column to a list or library

In order to use a formula in a list or library, you must add a calculated column to the list or library.

1. If the list or library is not already open, click its name on the Quick Launch.

If the name of your list or library does not appear, click View All Site Content, and then click the name of your list or library.

2. On the Settings menu , click Create Column.

3. In the Name and Type section, type the name that you want in the Column name box.

4. Under The type of information in this column is, click Calculated (calculation based on other columns).

5. In the Additional Column Settings section, enter the formula that you want to use in the Formula box. You can select items from the Insert Column box and then add functions, constants, and operators to the formula.

6. Select the data type that you want to be returned by the formula, and then click OK.

Note   The formula in a calculated site column can reference only other site columns that are in the same list or library. Therefore, when you add the calculated site column to a list or library, you must also add the site column that is referenced in the formula. For more information, see Make a calculated column available to other lists or libraries in this article.

## Make a calculated column available to other lists or libraries

If you have a formula that you want to use frequently in multiple lists or libraries, you can add a calculated column to the list of site columns. This makes the column and its formula available to any list or library in the site or subsites. For example, you can create a calculated column called Expiration Date by using a formula that returns the date 30 days from the value of the Start Date column (=[Start Date]+30). Then you can reuse the formula without recreating it in each list or library.

Notes

• The formula in a calculated site column can reference only other site columns that are in the same list or library. Therefore, when you add the calculated site column to a list or library, you must also add the site column that is referenced in the formula. In the previous example, you would need to add both the Expiration Date and the Start Date site columns to your list.

• If your new calculated site column needs to reference other columns in a list, you must first make those columns site columns in order to use them in the formula.

1. On the Site Actions menu , click Site Settings.

Note   On a site for which the Site Actions menu is customized, point to Site Settings, and then click the settings that you want to view.

1. In the Galleries column, click Site columns.

2. On the list toolbar, click Create.

3. In the Name and Type section, type the name that you want in the Column name box.

4. Under The type of information in this column is, click Calculated (calculation based on other columns).

5. In the Additional Column Settings section, enter the formula that you want to use in the Formula box. You can select other site columns from the Insert Column box and then add functions, constants, and operators to the formula.

6. Select the data type that you want to be returned by the formula, and then click OK.

## Add a calculated site column to a list or library

After you create a calculated site column, you can add it to any list or library in the site or subsites.

Note   If you edit the column formula in a specific list or library, the changes to the formula apply only to that list or library.

1. If the list or library is not already open, click its name on the Quick Launch.

If the name of your list or library does not appear, click View All Site Content, and then click the name of your list or library.

1. On the Settings menu , click List Settings, or click the settings for the type of library that you are opening.

For example, in a document library, click Document Library Settings.

2. Under Columns, click Add from existing site columns.

3. In the Select Columns section, select the group that contains the site column from the Select site columns from list.

4. In the Available site columns box, select the columns to add to the list, and then click Add.

Note   If the calculated site column that you are adding contains other site columns, you must add them to the list. You can hide the other columns later if you do not want them to appear in the list or library.

5. If you do not want the column to be added to the default view of the list, clear the Add to default view check box.

6. Click OK.

Applies To: SharePoint Server 2007

﻿