Skip to main content
Nintex Community Menu Bar

Hello everyone, 

I'm completely new here and also very new in using nintex for SharePoint. 
I have the following challenge and try to explain it with an example. 

 

In List A I have several coloumns (e.g. "kind of dress"; "colour of dress"; "size of dress"; etc.) --> structure

In every line I have a number (quantity) for every case in a coloumn. 

E.g. t-shirt; red; XS;..; 3


What I need need now is a workflow that calculate the total amount (based on the quantity of every line) of every possible "composition". --> t-shirt; red; XS;..; 103

It doesn't matter if this will be done in the current list or in another list. The easiest way will be prefered. 

 

I know that I have to work with query, for each and calculation. I also know that I have to use certain variables and collection. But I tried a lot and didn't reach the target until now. 

 

What I used so far was concatenate the items (t-shirt; red; XS) to use this as a variable but without any benefit. 

 

Your help is much appreciated.

 

BR

Mats

 

 

Just making sure I am reading this correctly. When you say that you want the "total amount", if your list looks like this: 

























































Kind of Dress Color of Dress Size of Dress Qty
Shirt Red XL 10
Pants Jeans SM 10
Shirt Blue XS 5


 



Then you just want to get the answer of "25" somewhere? If so, where do you want to use that total value, or where should it be stored? 


Hi Megajerk, 



maybe my short explanation is a little bit misleading. I try to be more detailed:



 



List 1 (source List)





























































































kind of dress colour of dress Size of dress QTY
Shirt Red XL 10
Pants Jeans M 10
Shirt Blue XS 5
Socks black  L 5
Pants Jeans M 5
Shirt Red XL 6


 



What I need to achieve is the to get total amount (every dress in a certain colour and a certain size) in another list (target list). I hope this makes it much transparent.















































































kind of dress colour of dress Size of dress QTY explanation of total 
Shirt Red XL 16  based on 10+6 (from source list)
Pants Jeans M 15 based on 10+5 (from source list)
Shirt Blue XS 5  
Socks black  L 5  

Okay, I think I got it, also is this question here (https://community.nintex.com/t5/Nintex-for-SharePoint-Forum/Transfer-Data-without-duplicates-from-List-A-to-List-B/td-p/227061) related to this problem because I think I can solve both. Just need a little time to work up a solution workflow when I wake up from sleeping 🙂 



 



Sorry for the delay!


No worries 🙂



 



Yes the other question is related to the same problem. 



I think that it makes sense to eliminate the duplicates first, but I'm curious about your solution. 



 


Actually, sorry, one last question. What happens if you have:



 

























































Kind of Dress Color Size Qty
Shirt Red XL 10
Shirt Red M

2



Shirt Red XL

10





 



Do you want the results to look like: 













































Kind of Dress Color Size Qty
Shirt Red XL 20
Shirt Red M

2





 



Where it only combines items that share the same three properties?



 



Sorry but there were no examples setup like this in your previous table. 


Yes, correct.



It has to be a line (in the target list) which is unique in case of the properties.


You got it!


So I think I have a solution, but just a few more questions. Sorry for the delay



 



Should the contents of the Inventory Totals List always only contain items that exist in the first Inventory List? 



 



So if I'm summing things from List A and placing their Totals into List B, if List B already had items in it previously, should they be saved or do they get deleted? 


List B is empty. 
And if there would be an update in list A all items in list B will be deleted prior the transfer to list B. 
Thus, no additional calculation or deletion of ‚new’ totals in list B is needed.


So let's say that I have two Lists. An Inventory list which contains an assortment of items, some of which might have the same values:





 



 



And an Inventory Totals list, where I want a total of items with matching Kinds, Colors, and Sizes to be tallied:





 



Both Lists have the same Columns configured in the same way:





 



To properly calculate the totals of similar items in the Inventor List into the Inventory Totals List, I am using the Attached workflow. 



 



The workflow works by getting all of the relevant columns (in this case [Kind of Dress], [Colour of Dress], [Size of Dress], and [qty]) from the Inventory List, and then iterating through one of those collections to generate a unique "Key" for each item.



 



A "Key" is just a combination of the Columns that will determine what constitutes a "unique" filter. In this case it's the [Kind of Dress], [Colour of Dress], and [Size of Dress] columns. It will combine those column values into a single string of text (the key).



 



Using the first item in the Inventory List as an Example:





Its key would be "Shirt;Red;S"



 



After the Key is made, the workflow performs a quick evaluation. It checks to see if the NewKey exists in a collection called var_NewKey_Collection, and stores the resulting Index in var_ExistinKey_Index. When you check a collection for a value, if the value is NOT found then the Index will be -1. However, if the value is found, then the index will be Greater Than -1.



 



If the value was not found, then the QTY value in the var_QTY variable is pushed into a block of XML. The reason I pushed the QTY into a block of XML is because Nintex Workflow Collections have no option to "replace" a value at a given index, which makes it difficult when you'd like to update the value of something that's in a collection. So, instead of worrying about that, I can easily get / replace the value of an XML node with no extra step needed to remove the old bad value that I was trying to update.



 



The XML generated looks something like this:



<QTYs>

<QTY>1</QTY>

<QTY>2</QTY>

<QTY>3</QTY>

<QTY>4</QTY>

<QTY>5</QTY>

<QTY>6</QTY>

<QTY>7</QTY>

<QTY>8</QTY>

<QTY>9</QTY>

<QTY>10</QTY>

<QTY>11</QTY>

</QTYs>



 



However if the NewKey is indeed found inside of the NewKey_Collection, then that means we need to Add the current Item's QTY to the QTY that is already stored for a duplicate item in the XML. To do this I Query the XML for the QTY which matches the ExistingKey_Index value + 1. This provides me with the OldQTY value which I can then add to the QTY variable using a Math Action resulting in the NewQTY, that I then use to Update the XML back at the same node (ExistingKey_Index + 1). 



 



(note: xml xpath uses a base 1 starting point for arrays unlike Workflow Collections which start at 0. So any Index position we get from a Collection will need to have 1 added to it in order to correctly match its position in the XML document that was generated to be paired with the Collection data)



 



That leaves me with a Collection of Unique Keys (NewKeys_Collection) and an XML document of all of the QTY totals. Using the example Inventory List above the Collection would now look like:



Shirt;Red;S;

Shirt;Blue;S;

Pants;Jeans;M;

Pants;Khaki;L;

Shirt;Black;XL

Shirt;Red;M;

Shirt;Red;XL;

Shirt;Blue;XS;

Socks;Black;L;


 



and the XML would look like:



<QTYs>

<QTY>1</QTY>

<QTY>2</QTY>

<QTY>13</QTY>

<QTY>4</QTY>

<QTY>5</QTY>

<QTY>6</QTY>

<QTY>18</QTY>

<QTY>8</QTY>

<QTY>9</QTY>

</QTYs>


 



You can see that both contain 9 items, and that the orders are correctly aligned. 



 



At this point it's just a matter of looping through each value in the NewKeys_Collection, splitting the Key back into its individual parts using a Regular Expression Action, getting the QTY value from the XML, and pushing all of those values into a New Item Action to generate a new Item in the Inventory Totals List. 



 



All of that work results with turning this:





 



Into This:





 



 Again, please see the attached Workflow as it should be fairly straight forward with how it's working once you're able to really look at it. Let me know if you need any additional help or have any questions about why I decided to do one thing instead of a different thing. 



 



 



 



 



 


Man, that was a lot of work and believe me I really appreciate your effort. Thanks a lot. 
The solution will definitely work for me. But could you please add how you fill/configurate the "query list"?


Ah not a problem. I was in a rush and forgot somethings wouldn't come through correctly in the Exported Workflow. 



 



The first Query List action is just pointed towards my Inventory List:





 



Additionally here is the Create Item's configuration:





 



Last but not least, I'm just using the "Enable Workflow Start From Item Menu" option to run the workflow from any item in the Inventory List. It doesn't really matter which one:





 



You may want to make this into a Site Workflow so that it's less "List Specific". I just wanted to get a proof of concept working. 




Besides those action configurations, were you able to import the workflow correctly? 



 



Let me know if you need any additional help. 



 


Awesome, thanks a lot. It works. 
I was able to import your workflow. Of course, I had to make a few adjustments (dress, colour, etc. was only an example), but to make the needed adjustments was very easy with the detailed description. 



 



Again, thank you very much. I'm overwhelmed.


Happy to hear that it has worked!


Reply