2 Simple Techniques for Creating SharePoint Views Grouped by Date Columns

Here are 2 techniques for creating views in SharePoint when you want to group on dates. Throughout this article I’ll be using the example of email that have been saved to SharePoint where the email date has been stored in a SharePoint column called “Email Date”. The Email Date is saved with both a date and time component.

sharepoint-views-date-group-by-cameron-dwyer-01-email-date-column

Here’s the All Documents view of the library showing the Email Date column

sharepoint-views-date-group-by-cameron-dwyer-02-all-documents

If we try to use the Email Date column to group by in the view

sharepoint-views-date-group-by-cameron-dwyer-03-group-by-email-date

The view creates a group for each different day (the time component is ignored)

sharepoint-views-date-group-by-cameron-dwyer-03-view-grouped-by-date

2 Level Grouping: by Year and then by Month

This view is going to get very busy with a grouping for each day, so how about we split it up a bit by creating 2 levels of grouping, firstly by year and then by month.

Unfortunately we can’t just use the existing Email Date column to achieve this, instead we will create two calculated columns to use for the groupings (one for year and another for month).

To create the year column:

Create as a calculated column
Set the returned data type as Single line of text (this gives better formatting control and the year will still sort properly as text)
Set the formula to =TEXT([Email Date], “yyyy”)

sharepoint-views-date-group-by-cameron-dwyer-04-calculated-year-column

To create the month column:

Create as a calculated column
Set the returned data type as Single line of text (this gives better formatting control and by padding a single digit month with 0 will still sort properly as text)
Set the formula to =TEXT([Email Date],”mm (mmmm)”)

sharepoint-views-date-group-by-cameron-dwyer-04-calculated-month-column

Now if we create a new view (based on the All Documents view) and add two levels of grouping based on our new calculated columns

sharepoint-views-date-group-by-cameron-dwyer-05-view-group-by-year-then-month

Our new view now renders in SharePoint giving collapsible grouping at both the Year and Month levels

sharepoint-views-date-group-by-cameron-dwyer-06-view-result-group-by-year-then-month

This is now a lot easier to navigate and drill down, and it’s quite nice to see the counts against each grouping as well. In this example I set the groups (both Year and Month) to sort in descending order. This means that the latest will be at the top (notice 2016 is above 2015, and within 2016, February is above January).

Faking a 3 Level Grouping: by Year/Month Combined and then by Day

SharePoint has a limitation in that you can only create two levels of grouping. If we want to have a third level (under month) that grouped together all the email from the same day then we can’t just go and add a third level of grouping. What we can do instead though is create a slightly more complex calculated column that combines both the year and month and use it as our top level grouping. So let’s do that now by creating a Year/Month column:

Create as a calculated column
Set the returned data type as Single line of text (this gives better formatting control and we can carefully craft the text so it still sorts year/month properly as text)
Set the formula to =TEXT([Email Date],”yyyy-mm (mmmm)”)

sharepoint-views-date-group-by-cameron-dwyer-07-calculated-column-year-month

We are also going the need a calculated column to group on the specific day, so I’ll create the Day column

Create as a calculated column
Set the returned data type as Single line of text
Set the formula to =TEXT([Email Date],”dd (ddd, d mmm yyyy)”)

sharepoint-views-date-group-by-cameron-dwyer-08-calculated-column-day

Now we create our new view (based on the All Documents view) and add groupings based on the Year/Month column and the Day column. Again we will sort descending to get the latest at the top.

sharepoint-views-date-group-by-cameron-dwyer-09-view-settings-group-year-month-day

The resulting SharePoint view gives us the year/month breakdown at the first level and we can then drill down to a specific day within the month.

sharepoint-views-date-group-by-cameron-dwyer-10-view-group-by-year-month-day

I’m sure you can now go forward and add your own tweaks and formatting changes to get better date categorized views out of SharePoint.

 

Advertisements

About Cameron Dwyer

Architect and developer at OnePlace Solutions. Passionate about delivering compelling solutions on the Office 365/SharePoint platform. Addicted to coffee.

Posted on March 1, 2016, in Office 365, SharePoint and tagged , , , , , . Bookmark the permalink. Leave a comment.

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

%d bloggers like this: