<?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 Left Join of 2 tables with a partial string match in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228461#M80487</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;Thanks for the quick reply.&lt;/P&gt;&lt;P&gt;Unfortunately I'm not sure that option is available to me because the product names don't have any common delimiter (sorry my example should've included some).&lt;/P&gt;&lt;P&gt;As well a products with names like 'ABC 123' they can also be 'ABC-123' and there may be other variations. If I could make assumptions on delimiters that would be the way forward but I was hoping that there might a solution that was more general.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Feb 2011 12:44:39 GMT</pubDate>
    <dc:creator>r3iuk</dc:creator>
    <dc:date>2011-02-24T12:44:39Z</dc:date>
    <item>
      <title>Left Join of 2 tables with a partial string match</title>
      <link>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228459#M80485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Say I have a Product table such as:&lt;/P&gt;&lt;P&gt;Product Quantity&lt;BR /&gt;ABC 123 500&lt;BR /&gt;ABC 234 1000&lt;BR /&gt;WXYZ 5000 100&lt;BR /&gt;WXYX 4000a 150&lt;/P&gt;&lt;P&gt;And a Product Type table such as:&lt;/P&gt;&lt;P&gt;ProductType Price&lt;BR /&gt;ABC 400&lt;BR /&gt;WXYZ 250&lt;/P&gt;&lt;P&gt;The product type is always at the beginning of any product name but could be of a varying length.&lt;/P&gt;&lt;P&gt;What I want to do is create a join of the tables that will give:&lt;/P&gt;&lt;P&gt;Product Price&lt;BR /&gt;ABC 123 400&lt;BR /&gt;ABC 234 400&lt;BR /&gt;WXYZ 5000 250&lt;BR /&gt;WXYX 4000a 250&lt;/P&gt;&lt;P&gt;I've tried the following:&lt;/P&gt;&lt;P&gt;Product:&lt;BR /&gt;LOAD *&lt;BR /&gt;FROM PRODUCT.qvd (qvd);&lt;/P&gt;&lt;P&gt;LEFT JOIN (Product)&lt;BR /&gt;LOAD&lt;BR /&gt;ProductType&lt;BR /&gt;Price&lt;BR /&gt;FROM ProductType.qvd (qvd)&lt;BR /&gt;WHERE Left(Product, Len(ProductType)) = ProductType;&lt;/P&gt;&lt;P&gt;The left join statement clearly won't work because the Product field is not available in the ProductType table.&lt;/P&gt;&lt;P&gt;Any ideas on how I can achieve what I need to do? I realise that I could do a full cartesian product on both tables then filter out the appropriate rows, but this is going to be too inefficient due to the volumes of data in the 2 tables.&lt;/P&gt;&lt;P&gt;Thanks for any help you can provide.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 12:20:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228459#M80485</guid>
      <dc:creator>r3iuk</dc:creator>
      <dc:date>2011-02-24T12:20:49Z</dc:date>
    </item>
    <item>
      <title>Left Join of 2 tables with a partial string match</title>
      <link>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228460#M80486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In this particular example, it makes sense to create ProductType field in the 1st table, and join by it:&lt;BR /&gt;Product:&lt;BR /&gt;LOAD&lt;BR /&gt;*,&lt;BR /&gt;subfield(Product, ' ', 1) as ProductType&lt;BR /&gt;FROM PRODUCT.qvd (qvd);&lt;/P&gt;&lt;P&gt;LEFT JOIN (Product)&lt;BR /&gt;LOAD&lt;BR /&gt;ProductType&lt;BR /&gt;Price&lt;BR /&gt;FROM ProductType.qvd (qvd)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 12:33:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228460#M80486</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-02-24T12:33:35Z</dc:date>
    </item>
    <item>
      <title>Left Join of 2 tables with a partial string match</title>
      <link>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228461#M80487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;Thanks for the quick reply.&lt;/P&gt;&lt;P&gt;Unfortunately I'm not sure that option is available to me because the product names don't have any common delimiter (sorry my example should've included some).&lt;/P&gt;&lt;P&gt;As well a products with names like 'ABC 123' they can also be 'ABC-123' and there may be other variations. If I could make assumptions on delimiters that would be the way forward but I was hoping that there might a solution that was more general.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 12:44:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228461#M80487</guid>
      <dc:creator>r3iuk</dc:creator>
      <dc:date>2011-02-24T12:44:39Z</dc:date>
    </item>
    <item>
      <title>Left Join of 2 tables with a partial string match</title>
      <link>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228462#M80488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's why I said about the "particular example"...&lt;/P&gt;&lt;P&gt;I can think of a solution that should work for you, althgough it may be not the most elegant:&lt;BR /&gt;1. In a separate load, join all Products and all Types:&lt;BR /&gt;Map1:&lt;BR /&gt;LOAD DISCTINT Product FROM ...;&lt;BR /&gt;JOIN (Map1) LOAD DISTINCT ProductType FROM ...;&lt;/P&gt;&lt;P&gt;2. See if Product Type string exists in Product string:&lt;BR /&gt;Map2:&lt;BR /&gt;LOAD&lt;BR /&gt; Product,&lt;BR /&gt; if index(Product,ProductType)&amp;gt;0, ProductType, null()) as ProductType&lt;BR /&gt;RESIDENT Map1;&lt;/P&gt;&lt;P&gt;3. Create Map:&lt;BR /&gt;ProductTypeMap:&lt;BR /&gt;MAPPING LOAD DISTINCT&lt;BR /&gt; Product as A,&lt;BR /&gt; ProductType as B&lt;BR /&gt;RESIDENT Map2&lt;BR /&gt;WHERE len(trim(ProductType)&amp;gt;0;&lt;BR /&gt;DROP TABLES Map1, Map2;&lt;/P&gt;&lt;P&gt;4. Get Product Type into your 1st table:&lt;BR /&gt;LOAD&lt;BR /&gt; *,&lt;BR /&gt; applymap('ProductTypeMap', Product) as ProductType&lt;BR /&gt;FROM ...&lt;/P&gt;&lt;P&gt;If missed something, you can figure out from here...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 14:58:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228462#M80488</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-02-24T14:58:08Z</dc:date>
    </item>
    <item>
      <title>Left Join of 2 tables with a partial string match</title>
      <link>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228463#M80489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Michael, that works well, performance is OK too.&lt;/P&gt;&lt;P&gt;It just needed a NOCONCATENATE on the load in step 2 and a couple of brackets here and there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 16:51:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Left-Join-of-2-tables-with-a-partial-string-match/m-p/228463#M80489</guid>
      <dc:creator>r3iuk</dc:creator>
      <dc:date>2011-02-24T16:51:49Z</dc:date>
    </item>
  </channel>
</rss>

