Announcements filtering with calculated fields


Situation:
A customer asked me yesterday if it’s possible to create a view which shows only the announcements of the last three days and the ones that aren’t yet expired. 

You know that you can add filter conditions on a view but that piece of functionality is very limited.
Default you have two date columns ‘created’ and ‘expire’, both columns are Dat Time types.

Problem:
It’s not possible to type this in one of your filter view conditions:
created is greater or equal to [today] + day(3) 

Sharepoint will raise an error on the [today] + day(3) part.

Solution:
You can easily solve this by creating a calculated column of type DateTime and named it for example: Hot News Expire.
In the formula textbox of the column enter the follow formula: [created] + day(3). It’s possible to use more "excel-like functions" in a calculated field than in the filter options of a view or the filter of the Content Query Webpart. 

Every announcement has now an extra column with a DateTime value on which you can filter! 

So, no coding is necessary, just some extra configuration on your announcement list.

Advertisements
This entry was posted in Sharepoint. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s