<?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 Re: [Logical Problem]  Chat with all possible combinations in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611324#M225613</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have a look at attached. The following will give you all the subsets (except the empty set, but that can be added if need be) of your set Vlr. Not the prettiest of things, but it does the job. It also finds the total sum for each set, so you can compare in your chart what sum you are looking for. The only problem with this is that it won't list duplicate subsets, so it will only give one group (for example 4,6 will only be listed once). Also, it uses loops, so if your set is huge, this will have affect on how long the script takes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Chart.PNG.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/52765_Chart.PNG.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Used the calculated dimension:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if(Vlrsum =vSum,&amp;nbsp; Subset)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where vSum is the variable sum you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Feb 2014 14:37:46 GMT</pubDate>
    <dc:creator>jerem1234</dc:creator>
    <dc:date>2014-02-07T14:37:46Z</dc:date>
    <item>
      <title>[Logical Problem]  Chat with all possible combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611320#M225609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table with values and codes of transactions. I need to find all possible combinations of the sum(values) which will give me a fixed number.&lt;/P&gt;&lt;P&gt;For example, I have these values: 2,4,4,6,7,3,5 and the fixed number is 10:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to show in a dynamic table the combination of possible sum(values) that will give the number that I want, but there's more than&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; one combination, so I'll have to create groups with those combinations.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, 4 groups: 1st (2,3,5) ; 2nd (4,6); 3rd (4,6); 4th (7,3);&amp;nbsp; ==&amp;gt; 2+3+5=10 ; 4+6=10 ; 7+3=10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's what I have:&lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp; cod:&amp;nbsp; |&amp;nbsp;&amp;nbsp; Vlr&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp; 100&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; | &lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp; 101&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp; 102&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp; 103&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp; 104&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp; 105&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp; 106&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variable: vFixed = 10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And that's what I need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This table was created only as an example of the result that I'm looking for.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="example.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/52644_example.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help me?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 14:36:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611320#M225609</guid>
      <dc:creator />
      <dc:date>2014-02-05T14:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: [Logical Problem]  Chat with all possible combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611321#M225610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rodrigo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can not think on how doing what your are looking for in the script or the expressions. You probably should try with a macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry ;(&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 15:18:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611321#M225610</guid>
      <dc:creator>luis_pimentel</dc:creator>
      <dc:date>2014-02-05T15:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: [Logical Problem]  Chat with all possible combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611322#M225611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well.. as Luis says.. I don't think you can get that result in an object. I don't know about macros because I never use those... so assuming that all possible combinations can be from 2 or three different values I'd try to create all possible combinations and valid results in the script. Try the next:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13916185490248204" jivemacro_uid="_13916185490248204" modifiedtitle="true"&gt;
&lt;P&gt;LET vFixed = 10;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Combinations_temp:&lt;/P&gt;
&lt;P&gt;LOAD Distinct&lt;/P&gt;
&lt;P&gt;Cod, Vlr&lt;/P&gt;
&lt;P&gt;FROM YourSource;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;JOIN&lt;/P&gt;
&lt;P&gt;LOAD Distinct&lt;/P&gt;
&lt;P&gt;Cod&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Cod2,&lt;/P&gt;
&lt;P&gt;Vlr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Vlr2,&lt;/P&gt;
&lt;P&gt;2 as Flag_2Values&lt;/P&gt;
&lt;P&gt;Resident Combinations;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;CONCATENATE&lt;/P&gt;
&lt;P&gt;LOAD Distinct&lt;/P&gt;
&lt;P&gt;Cod,&lt;/P&gt;
&lt;P&gt;Vlr,&lt;/P&gt;
&lt;P&gt;Cod2,&lt;/P&gt;
&lt;P&gt;Vlr2,&lt;/P&gt;
&lt;P&gt;3 as Flag_3Values&lt;/P&gt;
&lt;P&gt;Resident Combinations;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;JOIN&lt;/P&gt;
&lt;P&gt;LOAD Distinct&lt;/P&gt;
&lt;P&gt;Cod&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Cod3,&lt;/P&gt;
&lt;P&gt;Vlr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Vlr3,&lt;/P&gt;
&lt;P&gt;3 as Flag_3Values&lt;/P&gt;
&lt;P&gt;Resident Combinations;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, you'll have to check which rows create a valid match with your variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_13916185490025477 jive_text_macro jive_macro_code" jivemacro_uid="_13916185490025477" modifiedtitle="true"&gt;
&lt;P&gt;Combinations:&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;/P&gt;
&lt;P&gt;LOAD DISTINCT&lt;/P&gt;
&lt;P&gt;Cod,&lt;/P&gt;
&lt;P&gt;Vlr,&lt;/P&gt;
&lt;P&gt;Cod2,&lt;/P&gt;
&lt;P&gt;Vlr,&lt;/P&gt;
&lt;P&gt;Cod3,&lt;/P&gt;
&lt;P&gt;Vlr3&lt;/P&gt;
&lt;P&gt;Resident Combinations_temp&lt;/P&gt;
&lt;P&gt;WHERE&lt;/P&gt;
&lt;P&gt;(RangeSum(Vlr,Vlr2)=$(vFixed) and Flag_2Values=2)&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;(RangeSum(Vlr,Vlr2,Vlr3)=$(vFixed) and Flag_3Values=3)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Drop table Combinations_temp;&lt;/P&gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 15:43:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611322#M225611</guid>
      <dc:creator>Carlos_Reyes</dc:creator>
      <dc:date>2014-02-05T15:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: [Logical Problem]  Chat with all possible combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611323#M225612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all thanks for bringing this in Qlikview. May be Qlikview experts can give a Qlikview solution, but what i have for you is a SQL server solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This type of problem is known as Knapsack Problem. Now if you execute the below script in SQL you get the desired results:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table #x &lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; id&amp;nbsp;&amp;nbsp;&amp;nbsp; int not null primary key,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; price numeric(12,4) not null&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT INTO #x&lt;/P&gt;&lt;P&gt;&amp;nbsp; (id, price)&lt;/P&gt;&lt;P&gt;VALUES&lt;/P&gt;&lt;P&gt;&amp;nbsp; (100,2),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; (101,4),&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; (102,4),&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; (103,6),&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; (104,7),&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; (105,3),&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; (106,5);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; with calc as (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select id as id, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cast(id as varchar(max)) as id_list, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cast(price as numeric(14,2)) as price&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from #x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where price &amp;lt;= 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; union all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select c.id, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p.id_list+','+ cast(c.id as varchar(max)),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cast((c.price + p.price) as numeric(14,2))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from #x as c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; join calc as p on p.id &amp;lt; c.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where c.price + p.price &amp;lt;= 10&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from calc&lt;/P&gt;&lt;P&gt;where price = 10&lt;/P&gt;&lt;P&gt;order by id_list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table #x&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 16:33:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611323#M225612</guid>
      <dc:creator />
      <dc:date>2014-02-05T16:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: [Logical Problem]  Chat with all possible combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611324#M225613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have a look at attached. The following will give you all the subsets (except the empty set, but that can be added if need be) of your set Vlr. Not the prettiest of things, but it does the job. It also finds the total sum for each set, so you can compare in your chart what sum you are looking for. The only problem with this is that it won't list duplicate subsets, so it will only give one group (for example 4,6 will only be listed once). Also, it uses loops, so if your set is huge, this will have affect on how long the script takes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Chart.PNG.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/52765_Chart.PNG.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Used the calculated dimension:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if(Vlrsum =vSum,&amp;nbsp; Subset)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where vSum is the variable sum you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 14:37:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Logical-Problem-Chat-with-all-possible-combinations/m-p/611324#M225613</guid>
      <dc:creator>jerem1234</dc:creator>
      <dc:date>2014-02-07T14:37:46Z</dc:date>
    </item>
  </channel>
</rss>

