This article describes how to pull data from the previous item of a list while working on the existing (or new) item. This no-code solution works in SharePoint 2010, 2013 and Office 365 SharePoint Online using SharePoint designer workflow.

Setting the scene

Consider a scenario where a list has been created with columns chosen as shown below. Somehow you need to keep a running count of the sum of the total number of planned and required hours spent and that count needs to be refreshed every time a new item is created. What this means is that when a new item is created we need to look up the 'Sum of Hours Planned' and 'Sum of Hours Required' of the previous list item and add it to the existing list item.

Below is also a screenshot of the columns of a list



Below is a screenshot of the entire workflow. In a nutshell, we are using the list item's ID to find the columns of the previous item, add those values to a new item column and then do the calculation. For the sake of this explanation, the workflow is two separate steps. This is not a requirement.

Get data from the previous item

By design the list item number increase in a sequential order hence we can assign a temporary number column called 'Current ID' set the current Id of the list item and then find the ID number of the previous list item. Below is a screenshot of the three actions.

Below is the most critical action and can also get confusing. We have added extra screenshots here. We are going to use the 'Set Field in Current Item' action. Below is what the action looks like when added and without any setup.

Click on field and select 'Previous Sum Of Hours Planned' Below is a screenshot

Click on Value and then click on fx. The fx doesn't show up until Value is clicked. Below is a screenshot

By default Current Item is the Data Source. Change that to Current List

You should now see more options as shown below.

Populate all the fields as shown below. Let's pause here to understand what and why we choosing these settings. The data source i.e. the list is the same so no worries there. We do want to get the 'Sum Of Hours Planned' from the previous list item and we are going to use the item ID of the previous list item as a reference. This is why we had to do the calculation above.

Below is what the action will look like

Do the same for the Sum of Hours Required.

Add previous and current items

This section is pretty straightforward. First, we are taking the new Hours Planned we just received, adding it to the Previous Sum Of Hours Planned and saving it to a variable.

Second, we are setting the Sum of Hours Planned and Sum of Hours Required using the two variables we created above.


I have created a video which walks you through the workflow and then adding items the list and sees how the workflow does the calculation.
In this example the I have used Office 365 with SharePoint Designer 2013, however, the workflow is fully functional in SharePoint 2010 and 2013 as well. Due to prior testing, the first list item's ID number is, however, the workflow works just as well when the new item ID is 1.

(Click Here to view higher resolution)


This very same solution can be built using Visual Studio or JQuery, however, those will require coding. What I have described here is a simple, no-code solution that can be achieved using either SharePoint designer 2010 or 2013.

See Also