Question

How to combine multiple similar items from one list into one item on another list

  • 14 June 2023
  • 7 replies
  • 210 views

Badge +2

This is in SharePoint 2016.

I have an employee time tracking system where the employee submits time for a given week to specific projects, each entry is its own item. Example below.

Employee Project Week  Time
John Doe ABD 1 12
John Doe XYZ 1 16
John Doe LMNOP 1 4

 

I need to take the separate items, filtered to the specific week, keep them associated to that employee, add the total time entered, and update a single list item in a different list with the new information. Like below.

Employee Total Week Time
John Doe 32

 

I did look through this forum post, but I am uncertain that it will work since I need it to not be associated by ID, but by employee. I am not an expert in Nintex by any means either so the clearer the instructions the better. 


7 replies

Userlevel 5
Badge +13

Hi @mstallings 

 

This is possible but can be a little specific to set up.

 

First you will need to set the workflow to query and store the list of unique users, you can do this from the target (totals) list if the users exist there already or do it from the source (project entry) list, if you do this from the project list then you will need to remove duplicates from the returned users. 

Now you have a list of all of the users that will be entered into the totals you need to get each of those users specific items.

Loop for each user > Query Project list for all items for this user > Store in a collection [Hours time]

 

Now you will have a loop that finds each users logged items, we need to go through them and add them together.

We do this by looping for each item and storing the hours by doing a math operation to add to a variable.

 

Now that we have the fully calculated value we can create the new item in the totals list and clear the variable for the next user.

 

 

A workflow built in this way will iterate through a whole list, sum all of the items for a specific user and create a record with that number. 

 

If you have issues with the instructions please let me know. 

Userlevel 5
Badge +20

Hi @mstallings 
Did Jake’s answer solve your question? 

Badge +2

Thanks @Jake 

 

When it comes to the first for each loop, do I need to put a filter in the query that specifies that particular employee? I guess I don’t 100% understand how that loop and query work together.

Userlevel 5
Badge +13

Hi @mstallings 

 

There are 2 loops here one inside another, 

 

first loop is for each unique individual, as the instance of this loop contains a single person you don’t need to filter as the “current item” is the filter. 

 

The second loop is inside the first one, this loop finds each record for the individual being processed in the current loop instance. 
 

to simplify. 
 

if I have a list of recipes containing ingredients and I wanted to record each recipe each ingredient is used in, I would first get a list of each of my different unique ingredients, now I know my ingredients I can check each recipe in my list for that ingredient and storing that for later use. 
 

this is essentially the same process you are describing as I understand. 
 

please let me know if you run into trouble and if I can assist you further. 

Badge +2

@Jake Ah okay.

Could you breakdown the second loop for me a bit more? I’m a little lost on what goes where in each step for that.

Badge +2

@Jake 

I can’t get the math operation to work. What am I supposed to calculate exactly? How it works in the for each loop makes no sense to me. And why can’t I just use a collection operation instead?

Userlevel 5
Badge +13

Hi @mstallings 

 

I will see if I can build a workflow example for you and provide the export, I may not be able to do it this week but I will take a look next week for you.

 

Jake

Reply