Saturday, November 13, 2010

Sharepoint Calculated columns

Calculated columns – An example

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.
(Excerpt from the Microsoft Web site)

Let me use this Microsoft example to walk you through the setup of calculated columns.

We first need to create our SharePoint tasks list (Site Actions > Create > Tasks).

It already includes a [Start Date] column, let’s add the [Date Completed] one:
- Select: Settings > Create Column
- Create a column called “Date Completed”, with type set as ”Date and Time”.
- Click OK

  • We are now ready to create our first calculated column:
    - Select: Settings > Create Column
    - Create a column called “Duration”, with type set as ”Calculated (calculation based on other columns)”
    - Enter the formula:
    = [Date Completed]-[Start Date]
  • - Click OK

Let’s take a look at the result:

As you can see, the result is incorrect when the [Date Completed] field is empty. To fix this, we’ll add a condition to our formula:
=IF([Date Completed]=0,”",[Date Completed]-[Start Date])

Now, the duration will only be displayed after the user enters a value for “Date Completed”:

No comments:


A sales engineer is someone who promise you a bridge, even when there's no river.