<?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 Cross join through nested for loops? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Cross-join-through-nested-for-loops/m-p/135360#M603102</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Most solutions I've found on how to simulate a cross join in Qlikview involved using a full outer on tables that don't share a commonly named field and then trim the rows in excess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am curious to find out is whether the same could be achieved using two for loops nested one in the other. I am not interested in whether it is a more/less efficient solution here, just in the technical feasibility.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In very-pseudo-code it would be something like:&lt;/P&gt;&lt;P&gt;for each row in table1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return field1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (string) concatenate field 1 &amp;amp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for each row in table2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return field2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should give us a table with the desired cardinality and just one field. Then we could use left() and right() to pull out the original fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I struggle putting this into proper Qlikview syntax, any idea? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Aug 2018 11:01:46 GMT</pubDate>
    <dc:creator>imark</dc:creator>
    <dc:date>2018-08-30T11:01:46Z</dc:date>
    <item>
      <title>Cross join through nested for loops?</title>
      <link>https://community.qlik.com/t5/QlikView/Cross-join-through-nested-for-loops/m-p/135360#M603102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Most solutions I've found on how to simulate a cross join in Qlikview involved using a full outer on tables that don't share a commonly named field and then trim the rows in excess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am curious to find out is whether the same could be achieved using two for loops nested one in the other. I am not interested in whether it is a more/less efficient solution here, just in the technical feasibility.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In very-pseudo-code it would be something like:&lt;/P&gt;&lt;P&gt;for each row in table1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return field1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (string) concatenate field 1 &amp;amp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for each row in table2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return field2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should give us a table with the desired cardinality and just one field. Then we could use left() and right() to pull out the original fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I struggle putting this into proper Qlikview syntax, any idea? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2018 11:01:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Cross-join-through-nested-for-loops/m-p/135360#M603102</guid>
      <dc:creator>imark</dc:creator>
      <dc:date>2018-08-30T11:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Cross join through nested for loops?</title>
      <link>https://community.qlik.com/t5/QlikView/Cross-join-through-nested-for-loops/m-p/135361#M603104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Igor,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope I understood it correctly, I think you can fix this as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;field1&lt;/P&gt;&lt;P&gt;FROM Table1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN (Table1) LOAD&lt;/P&gt;&lt;P&gt;field2&lt;/P&gt;&lt;P&gt;FROM Table2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table3:&lt;/P&gt;&lt;P&gt;NOCONCATENATE LOAD&lt;/P&gt;&lt;P&gt;field1&amp;amp;'|'&amp;amp;field2 AS NewField&lt;/P&gt;&lt;P&gt;RESIDENT Table1;&lt;/P&gt;&lt;P&gt;DROP TABLE Table1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case you will get every possibility from field2 for each field 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to untie the fields you can use: SUBFIELD(NewField,'|',1) (for field1) en SUBFIELD(NewField,'|',2) for field2&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2018 11:13:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Cross-join-through-nested-for-loops/m-p/135361#M603104</guid>
      <dc:creator>avkeep01</dc:creator>
      <dc:date>2018-08-30T11:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cross join through nested for loops?</title>
      <link>https://community.qlik.com/t5/QlikView/Cross-join-through-nested-for-loops/m-p/135362#M603106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for each loops will be much slower than joins.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2018 11:15:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Cross-join-through-nested-for-loops/m-p/135362#M603106</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2018-08-30T11:15:30Z</dc:date>
    </item>
  </channel>
</rss>

