<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to add 10 dynamic values in all possible combinations to get a sum in Digital Exchange</title>
    <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113681#M3816</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a problem that I'm not quite sure how to solve. I will be reading in up to 10 dynamic values in to an collection and out of this I need to combine some or all values to a set sum. The loop variant seems to complex to since it can be over 1000 different combinations. Does any one have a solution - is there a code I could use for combining all the values?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2024 05:51:22 GMT</pubDate>
    <dc:creator>emjemed</dc:creator>
    <dc:date>2024-09-10T05:51:22Z</dc:date>
    <item>
      <title>How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113681#M3816</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a problem that I'm not quite sure how to solve. I will be reading in up to 10 dynamic values in to an collection and out of this I need to combine some or all values to a set sum. The loop variant seems to complex to since it can be over 1000 different combinations. Does any one have a solution - is there a code I could use for combining all the values?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 05:51:22 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113681#M3816</guid>
      <dc:creator>emjemed</dc:creator>
      <dc:date>2024-09-10T05:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113699#M3817</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/46424"&gt;@emjemed&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you give us more details.&lt;/P&gt;&lt;P&gt;Dont hesitate to put screen shot because its not really clear for me&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 10:30:38 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113699#M3817</guid>
      <dc:creator>Mohamad_Dakkouri</dc:creator>
      <dc:date>2024-09-10T10:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113734#M3818</link>
      <description>&lt;P&gt;Hi!&lt;BR /&gt;I will try to see if I can make it a bit clear with a print.&amp;nbsp;&lt;BR /&gt;I have a &lt;EM&gt;system&lt;/EM&gt; which has rows much like excel (so I will take a print from excel), where different values should create an amount. The values, number of rows and the amount will vary for each case.&amp;nbsp; The rows that does not create the amount should be removed. So in this case all the rows except 4,5 and 7 will be removed. So what is left creates 173. In some case there will be no match for the amount and in some case there are multiple ways to create the amount.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emjemed_0-1726038001216.png" style="width: 237px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39321i8931F37105B4AD15/image-dimensions/237x239/is-moderation-mode/true?v=v2" width="237" height="239" role="button" title="emjemed_0-1726038001216.png" alt="emjemed_0-1726038001216.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 07:15:06 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113734#M3818</guid>
      <dc:creator>emjemed</dc:creator>
      <dc:date>2024-09-11T07:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113735#M3819</link>
      <description>&lt;P&gt;&lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/46424"&gt;@emjemed&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your system is a windows application or web browser application ?&lt;/P&gt;&lt;P&gt;What is the business rules to take a row ?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 07:40:25 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113735#M3819</guid>
      <dc:creator>Mohamad_Dakkouri</dc:creator>
      <dc:date>2024-09-11T07:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113736#M3820</link>
      <description>&lt;P&gt;It is a windows application and there is no real business rules regarding removing a row. The only thing is that the remaining rows should be added up to the amount. Which rows is not important for them.&lt;BR /&gt;If there is no match to the amount no rows should be removed.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 07:45:28 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113736#M3820</guid>
      <dc:creator>emjemed</dc:creator>
      <dc:date>2024-09-11T07:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113743#M3821</link>
      <description>&lt;P&gt;Ok,&lt;/P&gt;&lt;P&gt;that mean for example if the amount is equal to 12&lt;/P&gt;&lt;P&gt;And you have 2 3 5 6 1 2 2&lt;/P&gt;&lt;P&gt;You have to take for example 6, 5,1 because the sum is 12 ?&lt;/P&gt;&lt;P&gt;Or you need to take all the combinations that give you 12 ?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 08:26:20 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113743#M3821</guid>
      <dc:creator>Mohamad_Dakkouri</dc:creator>
      <dc:date>2024-09-11T08:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113744#M3822</link>
      <description>&lt;P&gt;Exactly, I only need one combination. So it that exempel case yes need&lt;SPAN&gt;&amp;nbsp;6, 5,1 that makes 12.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 08:34:52 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113744#M3822</guid>
      <dc:creator>emjemed</dc:creator>
      <dc:date>2024-09-11T08:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113758#M3823</link>
      <description>&lt;P&gt;&lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/46424"&gt;@emjemed&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's imagine you have retrieved all your rows in a collection like this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamad_747_0-1726048037016.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39322iCD4047146218F18D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Mohamad_747_0-1726048037016.png" alt="Mohamad_747_0-1726048037016.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and your target for instance is 12.&lt;/P&gt;&lt;P&gt;You need to follow these steps :&amp;nbsp;&lt;/P&gt;&lt;P&gt;Go to vbo collection Manipulation and open it.&lt;/P&gt;&lt;P&gt;Then right click here and click new&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamad_747_1-1726048179948.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39323i8DA67AF475072831/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Mohamad_747_1-1726048179948.png" alt="Mohamad_747_1-1726048179948.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;add a code stage and name it FindCombination and provide these inputs and output like this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamad_747_2-1726048284474.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39324i252D1912F5E504C3/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Mohamad_747_2-1726048284474.png" alt="Mohamad_747_2-1726048284474.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamad_747_3-1726048299848.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39325iBEFD1C4DD97B71F0/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Mohamad_747_3-1726048299848.png" alt="Mohamad_747_3-1726048299848.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;in code stage put this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim outputCollection As New DataTable&lt;BR /&gt;outputCollection.Columns.Add("Number", GetType(Integer))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim stack(0) As Object&lt;BR /&gt;Dim stackSize As Integer = 1&lt;BR /&gt;stack(0) = New Object() {0, 0, New DataTable()}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DirectCast(stack(0), Object())(2).Columns.Add("Number", GetType(Integer))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim currentStackIndex As Integer = 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;While currentStackIndex &amp;lt; stackSize&lt;BR /&gt;&lt;BR /&gt;Dim state() As Object = DirectCast(stack(currentStackIndex), Object())&lt;BR /&gt;Dim currentIndex As Integer = CInt(state(0))&lt;BR /&gt;Dim currentSum As Integer = CInt(state(1))&lt;BR /&gt;Dim currentCombination As DataTable = CType(state(2), DataTable)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If currentSum = target Then&lt;/P&gt;&lt;P&gt;outputCollection = currentCombination&lt;BR /&gt;Exit While&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim tempStack(0) As Object&lt;BR /&gt;Dim tempStackSize As Integer = 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For i As Integer = currentIndex To nums.Rows.Count - 1&lt;BR /&gt;Dim num As Integer = Convert.ToInt32(nums.Rows(i)("Number"))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If currentSum + num &amp;lt;= target Then&lt;BR /&gt;&lt;BR /&gt;Dim newCombination As DataTable = currentCombination.Copy()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Dim newRow As DataRow = newCombination.NewRow()&lt;BR /&gt;newRow("Number") = num&lt;BR /&gt;newCombination.Rows.Add(newRow)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If tempStackSize &amp;gt;= tempStack.Length Then&lt;BR /&gt;ReDim Preserve tempStack(tempStackSize)&lt;BR /&gt;End If&lt;BR /&gt;tempStack(tempStackSize) = New Object() {i + 1, currentSum + num, newCombination}&lt;BR /&gt;tempStackSize += 1&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If tempStackSize &amp;gt; 0 Then&lt;BR /&gt;If stackSize + tempStackSize &amp;gt; stack.Length Then&lt;BR /&gt;ReDim Preserve stack(stackSize + tempStackSize - 1)&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;For j As Integer = 0 To tempStackSize - 1&lt;BR /&gt;stack(stackSize) = tempStack(j)&lt;BR /&gt;stackSize += 1&lt;BR /&gt;Next&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;currentStackIndex += 1&lt;BR /&gt;End While&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;combination = outputCollection&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your page in the end should look like this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamad_747_5-1726048459056.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39327i960FBB1123C0BC16/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Mohamad_747_5-1726048459056.png" alt="Mohamad_747_5-1726048459056.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now if i make a test in allnumbers i will add these :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamad_747_6-1726048610918.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39328i99C4A52CFEA1A2E6/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Mohamad_747_6-1726048610918.png" alt="Mohamad_747_6-1726048610918.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My target number is for instance 12&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamad_747_7-1726048665585.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39329i907EF7575740BFFD/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Mohamad_747_7-1726048665585.png" alt="Mohamad_747_7-1726048665585.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When i run my code i will obtain this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mohamad_747_8-1726048746515.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39330i515C89AFC9E14BAD/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Mohamad_747_8-1726048746515.png" alt="Mohamad_747_8-1726048746515.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ensure that input DataTable (allnumbers) in my case&amp;nbsp; has a column named "Number".&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dont forget to add the input in the start stage and the output in the end stage and publish your action to use it in process&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Try it and let me know.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 10:04:09 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113758#M3823</guid>
      <dc:creator>Mohamad_Dakkouri</dc:creator>
      <dc:date>2024-09-11T10:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113769#M3824</link>
      <description>&lt;P&gt;It worked perfectly, a question is there an easy way to modify the code to also carry an column with rows? If the collection looked as below, that you also got which row the number was associated with.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emjemed_0-1726062397843.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/39333iFE0F5B7693CB95F1/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="emjemed_0-1726062397843.png" alt="emjemed_0-1726062397843.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 13:47:28 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113769#M3824</guid>
      <dc:creator>emjemed</dc:creator>
      <dc:date>2024-09-11T13:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to add 10 dynamic values in all possible combinations to get a sum</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113796#M3828</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/46424"&gt;@emjemed&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Happy that work for you&lt;/P&gt;&lt;P&gt;No need to code you can make a simple loop with filter to know which item has been retrived &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you have same number for instance 2 2 3 4&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be the first 2 2 in your main collection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 01:14:47 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/How-to-add-10-dynamic-values-in-all-possible-combinations-to-get/m-p/113796#M3828</guid>
      <dc:creator>Mohamad_Dakkouri</dc:creator>
      <dc:date>2024-09-12T01:14:47Z</dc:date>
    </item>
  </channel>
</rss>

