<?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: Create combinations of a set based on item count in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Create-combinations-of-a-set-based-on-item-count/m-p/1857389#M70769</link>
    <description>&lt;P&gt;Perfect! This works like magic! Thanks&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/146379"&gt;@stevejoyce&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
    <pubDate>Tue, 09 Nov 2021 21:54:16 GMT</pubDate>
    <dc:creator>markgraham123</dc:creator>
    <dc:date>2021-11-09T21:54:16Z</dc:date>
    <item>
      <title>Create combinations of a set based on item count</title>
      <link>https://community.qlik.com/t5/App-Development/Create-combinations-of-a-set-based-on-item-count/m-p/1856815#M70716</link>
      <description>&lt;P&gt;Hi Community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set where I need to create combinations based on the count of items I have.&lt;/P&gt;
&lt;P&gt;As I have 3 distinct items, my combinations should be in a set of 3.&lt;/P&gt;
&lt;P&gt;1 ID for each item. Can someone please help? I have attached the sample QS file.&amp;nbsp; Any help is highly appreciated.&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/146379"&gt;@stevejoyce&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46628"&gt;@sunny_talwar&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Sample Input:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Container, item, ID&lt;BR /&gt;&lt;STRONG&gt;C1, A, 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;C1, A, 3&lt;/STRONG&gt;&lt;BR /&gt;C1, B, 3&lt;BR /&gt;C1, B, 5&lt;BR /&gt;&lt;STRONG&gt;C1, C, 2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;C1, C, 6&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Sample Output:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 153pt;" border="0" width="204" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD width="68" height="19" style="height: 14.25pt; width: 51pt;"&gt;Container&lt;/TD&gt;
&lt;TD width="68" style="width: 51pt;"&gt;Combo&lt;/TD&gt;
&lt;TD width="68" style="width: 51pt;"&gt;Values&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;C1&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;1,3,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;C1&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;1,3,6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;C1&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;1,5,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;C1&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;1,5,6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;C1&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;3,3,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;C1&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;3,3,6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;C1&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;3,5,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;C1&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;3,5,6&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 08 Nov 2021 21:37:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-combinations-of-a-set-based-on-item-count/m-p/1856815#M70716</guid>
      <dc:creator>markgraham123</dc:creator>
      <dc:date>2021-11-08T21:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create combinations of a set based on item count</title>
      <link>https://community.qlik.com/t5/App-Development/Create-combinations-of-a-set-based-on-item-count/m-p/1856847#M70719</link>
      <description>&lt;P&gt;My thought is to unpivot the data, cross join, and then combine the new columns for each item.&amp;nbsp; this seems to work, maybe there's a cleaner or more straightfoward way, but i expect this to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;input:&lt;/P&gt;
&lt;P&gt;load * inline [&lt;BR /&gt;Container, item, ID&lt;BR /&gt;C1, A, 1&lt;BR /&gt;C1, A, 3&lt;BR /&gt;C1, B, 3&lt;BR /&gt;C1, B, 5&lt;BR /&gt;C1, C, 2&lt;BR /&gt;C1, C, 6&lt;/P&gt;
&lt;P&gt;D1, A, 1&lt;BR /&gt;D1, A, 3&lt;BR /&gt;D1, C, 6&lt;BR /&gt;]&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//syntax to find if field is item value&lt;BR /&gt;let vSpecialFieldSyntax = '&amp;lt;&amp;gt;';&lt;/P&gt;
&lt;P&gt;//unpivot data with specialsyntax&lt;BR /&gt;generic_data:&lt;BR /&gt;generic load Container, 'Field' &amp;amp; '$(vSpecialFieldSyntax)' &amp;amp; item, ID resident input;&lt;/P&gt;
&lt;P&gt;//join generic tables&lt;/P&gt;
&lt;P&gt;Set vListOfTables = ;&lt;/P&gt;
&lt;P&gt;For vTableNo = 0 to NoOfTables()&lt;/P&gt;
&lt;P&gt;Let vTableName = TableName($(vTableNo)) ;&lt;/P&gt;
&lt;P&gt;If Subfield(vTableName,'.',1)='generic_data' Then&lt;/P&gt;
&lt;P&gt;Let vListOfTables = vListOfTables &amp;amp; If(Len(vListOfTables)&amp;gt;0,',') &amp;amp; Chr(39) &amp;amp; vTableName &amp;amp; Chr(39) ;&lt;/P&gt;
&lt;P&gt;End If&lt;/P&gt;
&lt;P&gt;Next vTableNo&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CombinedGenericTable:&lt;/P&gt;
&lt;P&gt;Load distinct Container Resident input;&lt;/P&gt;
&lt;P&gt;drop table input;&lt;/P&gt;
&lt;P&gt;For each vTableName in $(vListOfTables)&lt;/P&gt;
&lt;P&gt;Left Join (CombinedGenericTable) Load * Resident [$(vTableName)];&lt;/P&gt;
&lt;P&gt;Drop Table [$(vTableName)];&lt;/P&gt;
&lt;P&gt;Next vTableName&lt;BR /&gt;&lt;BR /&gt;//dynamic variables used in load script to merge item columns &lt;BR /&gt;Set vListOfValues = ;&lt;BR /&gt;Set vListOfFields = ;&lt;BR /&gt;&lt;BR /&gt;for field = 1 to NoOfFields('CombinedGenericTable')&lt;BR /&gt;&lt;BR /&gt;let vFieldCheck = FieldName($(field), 'CombinedGenericTable');&lt;BR /&gt;&lt;BR /&gt;Trace vFieldCheck $(vFieldCheck);&lt;BR /&gt;&lt;BR /&gt;if Subfield(vFieldCheck, '$(vSpecialFieldSyntax)',1) = 'Field' Then&lt;BR /&gt;&lt;BR /&gt;let vListOfValues = vListOfValues &amp;amp; If(Len(vListOfValues)&amp;gt;0,' &amp;amp; ') &amp;amp; 'If(Len([' &amp;amp; vFieldCheck &amp;amp; ']) &amp;gt; 0,' &amp;amp; '[' &amp;amp; vFieldCheck &amp;amp; ']' &amp;amp; '&amp;amp; ' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ')';&lt;BR /&gt;let vListOfFields = vListOfFields &amp;amp; If(Len(vListOfFields)&amp;gt;0,' &amp;amp; ') &amp;amp; 'If(Len([' &amp;amp; vFieldCheck &amp;amp; ']) &amp;gt; 0,' &amp;amp; chr(39) &amp;amp; Subfield(vFieldCheck, '$(vSpecialFieldSyntax)',2) &amp;amp; chr(39) &amp;amp; ')';&lt;BR /&gt;&lt;BR /&gt;trace $(vListOfFields) vListOfFields;&lt;BR /&gt;&lt;BR /&gt;end if;&lt;BR /&gt;&lt;BR /&gt;next field&lt;/P&gt;
&lt;P&gt;final_table:&lt;BR /&gt;load&lt;BR /&gt;Container,&lt;BR /&gt;$(vListOfFields) as Combo,&lt;BR /&gt;left($(vListOfValues), len($(vListOfValues))-1) as Values&lt;BR /&gt;resident CombinedGenericTable&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;drop table CombinedGenericTable;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 22:53:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-combinations-of-a-set-based-on-item-count/m-p/1856847#M70719</guid>
      <dc:creator>stevejoyce</dc:creator>
      <dc:date>2021-11-08T22:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create combinations of a set based on item count</title>
      <link>https://community.qlik.com/t5/App-Development/Create-combinations-of-a-set-based-on-item-count/m-p/1857389#M70769</link>
      <description>&lt;P&gt;Perfect! This works like magic! Thanks&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/146379"&gt;@stevejoyce&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 21:54:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-combinations-of-a-set-based-on-item-count/m-p/1857389#M70769</guid>
      <dc:creator>markgraham123</dc:creator>
      <dc:date>2021-11-09T21:54:16Z</dc:date>
    </item>
  </channel>
</rss>

