Posts Tagged ‘Calculated Columns’

How To setup a SharePoint view filter to compare 2 list fields

Date:June 1st, 2010 Author: Tags: ,
Category: Filter, SharePoint Ideas Comments:2 ;

There are many instances where you might want to view a set of SharePoint list records which have been filtered on a comparison between values in 2 columns.  You might want to view a list of all sales reps who have failed to hit their targets: Actual SalesCredit Limit, or employees who have not used their full vacation entitlement: Vacation Entitlement>Days taken.

A customer recently contacted me with just this type of question :-

They use a SharePoint list to keep track of orders waiting to be manufactured and delivered – so amongst other fields they have Scheduled Delivery Date (which they have promised to a customer) and the Estimated Delivery Date which is kept up to date with the latest estimate. Most of the time the two agree but sometimes for various reasons the delivery date slips.

They have been using Reminder to send out automated emails for upcoming orders and ones that had just been missed but they wanted to setup a view that would show only orders where the Estimated delivery date was later than the date they had told the customer. Account managers could then use this list to keep customers up to date – “There is a delay on that order we have scheduled for you for next month, we estimate it will be ready on the 17th”

Sounded pretty simple to me and I confidently told them how they could do it (more…)

SharePoint Calculated columns – Adding hours onto a date field

Date:May 18th, 2010 Author: Tags: , , ,
Category: General, SharePoint Ideas Comments:7 ;

A customer recently contacted me with an interesting question.

They were using a SharePoint task list to help schedule jobs for field engineers but rather than have a Start Date and End Date field they wanted to have a Start Date and Duration field and automatically work out the End Date.

So End Date = Start Date + Duration

They were then planning to display this using Planner in the By Category view which is idea for resource booking as it makes it easy to see when a resource is booked or free (SharePoints built in gantt chart can’t do this swimlane style of view and doesn’t support using calculated columns).

Now this is easy to do if the Duration is specified in days – in fact you just use the equation above – but what if Duration is in hours or minutes?

First port of call is this page from Microsoft showing examples of common date time formula you can use in SharePoint calculated columns hmmm, adding days OK… adding months Check… adding years OK too….but nothing about hours. Back to the drawing board.

(more…)

How To Use Filters in SharePoint to show items in the current Calendar Month

Date:November 26th, 2009 Author: Tags: , , ,
Category: Calculated Columns, Filter, SharePoint Ideas Comments:202 ;

Its very easy using the Filter feature of SharePoint views to show only items completed in the last 30 days or items due in the next X days; for example :-

Completed >= [Today]-30

On the Advanced SharePoint View and Filter techniques post Ed asked how you could filter for the current calendar month rather than a rolling 30 day period (for example all tasks due this calendar month).

Like all great questions it seemed simple enough – something like only showing items where the Month and Year of the due date = the Month and Year of the current date.

(more…)

Tip – Showing multiple columns in SharePoint Planner Webpart

Date:October 14th, 2009 Author: Tags: , , , , , ,
Category: Calculated Columns, SharePoint Planner, SharePoint webparts Comments:1 ;

There may be times when you want to display timeline or category information from more than one list column in a gantt chart. For example in the chart below we have taken information from the “priority” and “title” columns of a list to populate the category labels.

With Planner you can show multiple columns in the Category or on the Timeline of a Gantt chart by using a calculated column to merge fields together.

concat-columns
For example to merge Priority and Title columns together you would :-


  • From your list click Settings > Create Column
  • Set a name such as “Category”
  • Choose Calculated for the type
  • In formula enter (where [Title] etc is the name of the columns you want to merge)
      =[Priority] & " : " & [Title]
  • Uncheck ‘Add to default view’ checkbox if you don’t want this appearing for the normal list view.
  • In Planner you can now select this column.

You can merge multiple columns together, for example :-

   =[Priority] & " : " & [Title] & " - " & [Assigned To]

You can also use SharePoint standard functions and formula (many similar to excel) such as :-

   =Text([Start Time],"mmm-yyyy") " : " & [Title]

Which would prefix the Title with Month and year, like so  October-2009 : Your title here

To display the the duration in days you could use

   =DATEDIF([Start Time],[End Time],"d") & " Days"

See some more examples of common functions

SharePoint Reminder Webpart – Setting a variable Due In or Overdue By time

Date:June 12th, 2009 Author: Tags: , , ,
Category: Calculated Columns, SharePoint Reminder, SharePoint webparts Comments:2 ;

When you normally setup SharePoint Reminder webpart you can specify to send an email alert when a date is Due In X days or Overdue by X days




When column Service Date is due in 5 days




One fairly common requirement amongst users of Reminder is the ability to set variable ‘Due In’ or ‘Overdue By’ times. For example lets imagine the scenario of a company using SharePoint and Reminder to help control the servicing of various pieces of equipment.

(more…)

The Truth about using [Today] in SharePoint Calculated Columns

Date:November 22nd, 2008 Author: Tags: , ,
Category: Calculated Columns, SharePoint Ideas Comments:32 ;

If you try to create a calculated column with a formula containing [Today] or [Me] SharePoint gives the error :

“Calculated columns cannot contain volatile functions like Today and Me”

There are a few reasons you might want to do this. One would be to display how many days left you have to complete something, the other is to only show things added in the last X days or due in the next X days.

There are many pages mentioning this workaround :-

1) Create a dummy column called “Today”, then add your calculated column using [Today] in the formula, finally delete the dummy column. If you need to edit the formula then you have to go back to the start and add the dummy column again.

2) Optionally you can create a calculated column called “My Today” and set its formula to =[Today] using the trick above. Reference [My Today] in your other calculated columns. Thus you reference [My Today] which in turn references [Today]. Then you will not have to add the dummy column back in every time you want to edit formulae.

You then pat your self on the back and head home after another successful day of harassing SharePoint to do what you want, Hurrah!

But the next day you take a look at your list and its wrong. The formula has not updated and its still showing yesterdays value. DOH! SharePoint has made a fool of you after all.

Turns around there is actually a good reason for SharePoint not allowing volatile functions like [Today] or [Me] in calculated columns.

“Calculated fields don’t update themselves until item itself is updated.”

Read that again.

The value of a calculated column is only updated when item is edited and in the mean time you will see incorrect calculations every time you look. In fact, for most uses, this trick don’t give you anything more than just referencing the [Modifed] column.

One workaround to the workaround problem is to write a console app to find all these lists that use the [Today] trick and update them automatically once per day. But this workaround to the workaround problem may not be without its own problems that need to be worked around….

Depending on your need there may be a simpler way – turn the problem on its head!

In the example of using a calculated column to filter out items due in x days or overdue SharePoint will accept [Today] as part of the Filter but will not as part of a calculated column – so give it what it wants

[EDIT- WSS 3 / MOSS 2007 now accepts this]

  • Use a filter of [Created] is greater than [Today]-7

(Note – its essential to have no spaces; [Today] – 7 will not work but [Today]-7 does.

WSS 2 / SPS 2003

  • Create a column called “Filter 7 Days” and formula as =Created+7
  • Then use a filter of “Filter 7 Days” is less than [Today]

See this page for more details – http://blog.pentalogic.net/2008/10/advanced-sharepoint-view-and-filters/

So the calculated column is not dynamic (it will never need updating unless the record itself changes) and SharePoint is happy – but the filter is dynamic and you are happy!

If you want a countdown in your view (i.e. Days left to complete a task) then take a look at this post – http://pathtosharepoint.wordpress.com/2008/08/25/a-countdown-for-tasks-lists/

Shameless plugs

– check out our Highlighter product if you want count-down to Today (e.g. 5 days left, 10 days overdue)

– or check out Reminder if you want “Alert Me” type emails when a task is due soon or overdue.

[EDIT] As it’s been pointed out to me the tone of this article was off from what I intended – the intention is to make clear that this well known and oft mentioned trick does not work as you might expect and to offer alternatives.

Free SharePoint Calculated Column Cheat Sheet
a handy 3 page reference for calculated column functions and formulas.

Working Days, Weekdays and Holidays in SharePoint Calculated Columns

Date:November 21st, 2008 Author: Tags: , , ,
Category: Calculated Columns, SharePoint Ideas, SharePoint Reminder, SharePoint webparts Comments:30 ;

AcmeCorp aim to reply to customer complaints within 3 working days. They plan to use SharePoint Reminder webpart to alert managers when these targets are not being met.

We have a list with the following information

ID Title Date Received Reply Due Reply Sent
1 Order hasn’t arrived Friday 7/Nov/08 Wed 12/Nov/08
2 Order missing items Monday 10/Nov/08 Thursday 11/Nov/08

Once we have this table we could make a View with a filter to only show records that don’t yet have a Reply Sent date (i.e. they have not been dealt with) and then configure a Reminder web part to watch this view and send out emails when the Reply Due date is overdue.

(more…)