Thursday, December 9, 2010

Filter Calendar Events by Week or Month

A common task, when displaying calendar events in the Events web part, is to filter them so that the calendar events only for a specific period are displayed.  This is easily accomplished by adding a single calendar field and then configuring the Calendar web part's Filter. This isn't the only way to implement custom event filtering.  There are others, but this one is straigtforwardly implemented with just a few clicks.  Let's get started.
  1. The first thing to do is to create a new field.  Go to the Calendar page, and then select List Settings from the Settings drop down.
  2. On the Customize Calendar page, go down to the Columns section, and then look for the Create Column link in this section.  Click this link.
  3. On the Create Column: Calendar page, enter a name for the new field.  In this example, I have named it Due Date.  Configure the field format as Date and Time, and then uncheck the Add to default view option that you see lower down.
  4. Click OK.  The field will be created, and you'll be returned to the Customize Calendar page.  Go down to the Columns section, and you'll now see the new field you created.
  5. Now go back to the Calendar page, and create a new calendar event that is within one week of the current date.  In this example, today's date is 12/9/2010, and the calendar event is created for 12/10/2010.
  6. Once you have finished creating this date, create another one, but this one scheduled for more than one week in the future.  In this example, the second event was scheduled for 12/21/2010.
  7. Now go back to the main page of your site, where you have the Calendar web part, and you should see the two calendar events displayed there.
  8. On this web part, hover the cursor over the Calendar title until the dropdown appears, and then click this dropdown arrow. 
  9. On the popup menu, select Modify Shared Web Part.  This will open the shared version of the page.
  10. Looking to the right, you'll see a new section appear.  This section enables you to configure the web part.  On this section, look for Selected View, and then just below that, the Edit the current view link.
  11. Click this link.  This will take you to the Edit View: Calendar page.  On this page, scroll down to the Filter section.  Click the first drop down list under the label Show the items when.  A drop-down will open.  Scroll the drop down until you see the new field you created - in this example Due Date.
  12. Select this field.  It will then appear in the Show the items when column field.  For the second dropdown here, select is less than or equal to.  Lastly, in the text box, enter [Today]+6.
  13. Click OK.  You'll be returned to the main page, and you'll now see just one calendar event listed.
  14. That's it!  You're done. Congratulations!

No comments: