SharePoint grouping by week

Overview
In SharePoint 2007, to achieve grouping list items by week, a week start or week end date is required. Calculated columns can be used to work out the start day of the week and end day of the week.

Week starting Monday

=[Created]-WEEKDAY([Created],2)+1

Week starting Sunday

=[Created]-WEEKDAY([Created])+1

Week ending Saturday

=[Created]+7-WEEKDAY([Created])

Week ending Sunday

=[Created]+7-WEEKDAY([Created],2)

Week ending Monday

=[Created]-WEEKDAY([Created],2)+1+IF(WEEKDAY([Created],2)=1,0,7)

Screen shot:

List view issue when grouping by date
SharePoint 2007 has many glitches, grouping dates on the list view is one them. If you want to create a weekly list view using the week start or week end column that you created in the previoius section, you will likely see this error:

To work around this there are two options:

Option 1 – Expanded by default:

  • Edit your list view, under the Group By section, select Expanded for “By default, show grouping:”.
  • This is not ideal since, everything is expanded which pretty much defeated the purpose of grouping.
  • To further work around this, you can add a jQuery to collapse the groups. The downside is losing the SharePoint’s ability to remember the last expand and collapse groups.
  • Refer to a post by Spyral Out for more information and suggests of other alternatives.
The jQuery


Option 2 - Group by Text field
The other option is to change the week starting or ending calculated columns to a text field. However, the downside is that the date needs to be formatted as "yyyy/MM/dd" in order for sorting to work. For example:

=TEXT([Created]-WEEKDAY([Created],2)+1,"yyyy/MM/dd")

Conculsion
Both options have their pros and cons, it will be depend on what works for your users.

Spread the word. Share this post!

Leave A Reply

Your email address will not be published. Required fields are marked *