Have you ever wanted to show some summary information about a list, such as counts and totals for the entire list? This request has come up at least twice in the past few weeks on the MSDN blogs, so I wanted to create a blog post that shows a quick example of how you could solve this problem using InfoPath. Here is an example of one of the requests: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010general/thread/d2c07b63-fd4e-4a77-a506-2c52e144dd30
There are a few different ways that this can be accomplished, one way is to create a custom list view in InfoPath and then use the Form Web Part to display the data
Start by configuring your list in SharePoint. Once that is ready you will want to customize your list form using InfoPath Designer. Once you have the form opened in SharePoint Designer, you will want to create a new view:
This will give us a blank view to work with and will not have any impact on the current new and edit forms. In my example I am going to call the View “List Summary”.
Now we will need to create a data connection to our list. This will allow us to see our list as a whole. By default we have a connection to just the list item, but since we want to get a summary we want to look at a data source that contains all the list items. We are basically creating a data source to retrieve data from our current SharePoint list.
Select our list (for my example I am using the task list):
Select the fields that you will pull over:
Name the data source:
Now we are ready to build our form. I have created just a few fields to show the sum of the number of items and the number of closed or open items. You would just customize this to match what you were looking to display.
The next step is to populate the fields we created. For the Total Number of Tasks, we are going to set the field using the Count Function. You do this by right clicking on the field and selecting the Text Box Properties:
Now, select the Function icon next to the Value field. This will allow us to configure the value that is loaded by default when the form is loaded.
Select to Insert Function:
Select the Count Function:
When the function is displayed, select the option to double click and insert the field. In the Field or Group selection screen, select the data source we created above. Within that data source select the Title field. This will give us a count of the number of items in the list. Once you do this select OK until you are back at the form.
Now for the next field (Number of Completed Items) you will complete the same steps, but on the final step where you are selecting the field you will also add a filter.
Once you get the form completed (and published to the list), you can add it as a web part to any SharePoint page.
In the properties pane of the web part, configure the list and the view that you created above:
Now when the page loads you will see your summary view displayed as a web part:
Because the summary web part is not directly related to the list web part on the page they can both have a different focus. This means that I can create a custom view on the page that filters the data as well as show this summary that could apply to all content in the list.