Skip to main content

SharePoint list views by grouping data in Calculated columns




SharePoint list views by grouping data in calculated columns

The reason is simple: the initial display of the list view is smaller, and the user controls what to display by clicking a Plus/Minus button to expand/collapse a specific group of data. Generally speaking on the Web, the less data displayed, the faster it displays. Furthermore, clicking the Plus/Minus button does not refresh the entire page; it only loads the subset of data that is needed onto the current page.

The grouping part is straightforward. Create a view, edit the view, and then change this section of the Edit View form, which is fairly self-explanatory.


 
Here's what each additional view -- with one group level expanded -- looks like.

The "By Last Name" view


By Last Name view


The "By Birth Month" view

By Birth Month view

The "By Service Level" view

By Service Level view

Finally, here's how each view was defined in the Edit View form.


View
Columns and Order
Sort
Group By
Totals
All Items
Badge
Last Name (Edit)
First Name
Hire Date
DOB
Begins With
DOB Month
Years
Seniority 
Ascending Badge
NA
Count of Badge
By Last Name
Last Name (Edit)
First Name
Hire Date
DOB
Years
Seniority 
Ascending Last Name
Ascending First Name
Begins With
Collapsed
100 items per page

NA
By Birth Month
Last Name (Edit)
First Name
Hire Date
DOB
Years
NA
DOB Month
Collapsed
100 items per page

NA
By Service Level
Last Name (Edit)
First Name
Hire Date
Years
Descending Years
Ascending Last Name
Seniority
Collapsed
300 items per page
NA

As you can see, the Group By feature requires a list column to create and sort the group. Sometimes you already have a list column you can use, like a Department or Job Title. Other times, you need to create a calculated column to effectively group the data. That's where the fun comes in.

For more information on calculated columns, see Introduction to data calculations.

Let's take a look at a common scenario in any enterprise – viewing a subset of employee data. In this case, we have a list that contains employee data pertaining to hire dates, date-of-birth, and seniority level.

Each week, all the data is replaced with a new set of data from a master database -- containing new, updated, and deleted employees. A simple way to do this is to use Office Access 2007 to link to the list, and then each week, run a macro that deletes all the old data, and then appends the new data to the list.

The most common user requests for this set of data are easy ways to find:
·         Employee longevity information by last name.
·         The month an employee was born, so birthday celebrations won't be forgotten.
·         An employee's seniority level (5, 10, 15, and 20), so award ceremonies can be planned in advance.

To satisfy each requirement, let's create three views of the list that group the data appropriately based on calculated columns.

Here's what the All Items Employee Birthdays/Seniority list view, which contains over 1000 items, looks like.

All Items view

Here's a summary of the list metadata including the formulas used with the calculated fields.


Field
Type
Description
Formula
Example
Badge
Text 
The Employee's badge number.
NA
44819
Last Name
Text 
The employee's surname.
NA
Bacon
First Name
Text 
The employee's given name.
NA
Dan
Hire Date
Date/Time 
When the employee was officially hired.
NA
9/25/1996
DOB
Date/Time 
When the employee was born.
NA
6/28/1953
Begins With
Calculated Text
Calculates and displays the first letter of the last name for use with the view that groups names in alphabetical order.
=LEFT([Last Name],1)
B
DOB Month
Calculated Text
Calculates and displays the month of a person's birthday in three  character format, and prefix with the month number to sort by chronological order of months.
="("&TEXT(MONTH(DOB),"00")&")"&" "& CHOOSE(MONTH(DOB),
"JAN","FEB","MAR","APR","MAY","JUN", "JUL","AUG","SEP","OCT","NOV","DEC")
(06) JUN
Years
Calculated Number
Calculates and displays the number of full years based on an employee's hire date and the year of the current date.
=DATEDIF([Hire Date],Created,"Y")

Note   Because the data is replaced each week, the Created date always contains the current year. The third argument, "Y", ensures a full year is calculated.
12
Seniority
Calculated Text
Calculates and displays an employee's seniority level for awards granted every five full years of service up to 20 years.
=IF(Years<=5,"Level 05",IF(Years<=10,"Level 10",IF(Years<=15,"Level 15","Level 20")))
Level 15

We humbly submit to you that the Group By feature, introduced in Windows SharePoint Services 3.0, is underrated and underused. If your lists are getting bigger all the time and you are noticing a "slowdown", grouping data before it's displayed is a simple but effective way to improve performance and usability.



Did we hear you say, "Download a list template, please?"


For more information on list templates, see Share customizations by saving them as templates

If you have the time, group your thoughts together and calculate a reply. ;-)

Srikanth Gadiyaram

 











































Comments

Popular posts from this blog

Sharepoint 2010 Subsites webpart

This posting was originally made by Arild Aarnes and it is in here . This is a simple webpart to show a list (with links) of subsites immediately below the current site. This webpart will work on both Sharepoint 2010 and Sharepoint Foundation. On Sharepoint 2010 you could have used the built in “Table of Contents” webpart to do similar things but this one can also display the list as a dropdown list to save space on the webpage and it can open links in a new window. All the settings can by edited in the webpart configuration panel. The settings are: Show bullet in list – this will display the small square gif in front of the site name Open link in new window – this will open the subsite in a new window Show Site Description – this will show the description you entered when you created the subsite Show icon – Shows a icon for the type of subsite, see picture. Show as dropdown list – Will display the subsites in a dropdown box to save space. The webpart can be downl

Configuring the User Profile Service in SharePoint 2010

I will share with you my step by step guide in setting up the User Profile Service application, focusing on its configuration and administration and how we can enable the creation of user profiles via an Active Directory import . SharePoint 2010 introduces the notion of “Service Applications” which build’s upon the “Shared Services Provider (SSP)” which was introduced in SharePoint 2007.  Service Applications are individual services that can be configured independently and can be shared across other sites within your farm with some service applications that can also be configured across farms. The individual service applications provided with SharePoint 2010 are listed as follows; Access Services Business Data Connectivity Document Conversion Excel Services Managed Metadata Service PerformancePoint Search Service Secure Store State Service Visio Graphics Service User Profile Service This article will build upon our initial SharePoint 2010 install utilizing the least privi

The Text Filter Web Part – Without Having To Filter Exact Text

This posting I took it from  Here   This applies to both SharePoint 2007 and 2010.  In MOSS Enterprise, and the 2010 version of Enterprise.  There is an out-of-box web part called the Text Filter Web Part .  Basically, when you put this web part on a page, and put a list or library web part on the same page, you then create a web part connection that sends the text typed in the box as a filter to one of the columns in the web part, like this: The name Molly Clark had to be typed in exactly.  So, if you typed “Molly”, this record would not come up.  People use the text filter web part when they just want to search a single column in a list or library.  Otherwise, you’d simply use the “Search” box at the top of the screen, choose “This List” or “This Site” and perform SharePoint searches that way. One more note before I get into today’s solution: If you’re making use of site columns in your lists, there’s a setting where you can specifically select which columns you do N

Telephone format for a text box on infopath form

If you want to create a Telephone format on a infopath form : 1. Add a text field to the form (Even if it is the list or a blank form) 2. Select the text box and click on Manage Rules 4. Add a rule to your textbox control with the following conditions (make sure to select "and" operator):     a. field "does not match pattern" Phone number     b. the expression: string-length(translate(., "()- ", "")) = 10     c. the expression: string-length(translate(., "()- 0123456789", "")) = 0 5. Add action to the rule:     a. Set a field's value     b. Select your textbox field     c. Insert formula for the value (click the fx button): concat("(", substring(translate(., "()- ", ""), 1, 3), ") ", substring(translate(., "()- ", ""), 4, 3), "-", substring(translate(., "()- ", ""), 7, 4)) Link for the detailed explanation :  http:

HOWTO: change the home button text on the top link bar in sharepoint 2010

Hi All, I got a requirement that the title of the site collection which shows the first button on the top link bar to be different from the title. for example: my sharepoint site title is " Srikanth SharePoint Blog" and I need to show"Home" on the top link bar. It shows Home when the publishing features are not enabled. But once the publishing features are enabled it shows the same as the title("srikanth sharepoint blog" in my case instead of "Home").In other blogs I saw the solution as "in SITE ACTIONS>SITE SETTINGS>LOOK AND FEEL> TOP LINK BAR" , but once the publishing features are enabled, you don't see the "TOP LINK BAR" under "LOOK AND FEEL"(ofcourse it is changed to "NAVIGATION" , when publishing features are enabled). In this case : 1. Hide the initial button by adding code in css.    .s4-tn li.static > a{ display: none !important; } .s4-tn li.static > ul a{ display: bloc

SharePoint Branding and Design in 2010-2

Update: Really Small SharePoint Calendar I really was not that happy with the look of the first calendar so after some modifications and a bit of CSS magic I have come up with a really good looking small calendar. At least I think so… Basically I have replaced the text of an event item with a color coded box. The benefit that you get out of this is that you don’t have to try and read the even within the small calendar but if you hover over and click on the color block you get the list Item display. Orange is for single event items (8am-10am, etc) Green is for full day events or repeat events Another nice feature to this is that I have also simplified the visual indicator when there are more then two event items in one day. Instead of seeing the arrow and text all you see is the arrow. Once you click on the arrow it will show the other blocks of events (Right image). Here is the CSS Code: Download Here Simply place a content editor web part on the same page as the calendar

SharePoint Branding and Design in 2010

Hide First Tab in SharePoint 2010 Navigation I created a blog post on this for SharePoint 2007 HERE : But SharePoint 2010 is a bit more complex. Since it uses UL’s and Li’s for it’s navigation it is a bit harder to hide just one element. You will notice that the Home tab actually is the first node and then has a child UL which represents the rest of the navigation Items. So the approach is to hide the first <li> <a> (display: none) and then simply just use (display:block ) to show the hidden <ul> <li> <a> tags. Here is the CSS you could use to hide just the first node (home) tab in a SharePoint 2010 application: .s4-tn li.static > a{ display: none !important; } .s4-tn li.static > ul a{ display: block !important; } Enjoy! Posted by Erik Swenson at 12:12 PM 2 comments Labels: Branding , CSS , SharePoint 2010 Wednesday, August 18, 2010 How To: Hide Left Side Navigation on Home Page I was recently asked: " How can I hide the sid

Data View conditional formatting using SharePoint Designer

Data View conditional formatting using SharePoint Designer This article demonstrates how to use SharePoint Designer 2010conditional formatting to format items in a SharePoint (SPS 2010) list based on item metadata. The example uses a standard SharePoint task list and formats tasks based on the due date. The end result is a list view sorted by due date with item text or background coloured to represent the number of days until the due date. The Process In this example I have started with a standard task list and have created a few sample items for testing / demonstration. From the task list, create a new view, starting from the default “Active Items” view (filtered to only display incomplete tasks). The view created in the example is called “Active – Coloured” Open the view using SharePoint Designer. Right click on the List View Web Part and select “Convert to XSL Data View”. This will automatically convert settings for the current view into da