<?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 Setting a field value in Load based on substring from separate table in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241126#M91577</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There might be a simpler way, but I think this would work (untested):&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// load your raw data&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;CourseCompletion:&lt;BR /&gt;LOAD&lt;BR /&gt; Station&lt;BR /&gt;,CourseTitle&lt;BR /&gt;...&lt;BR /&gt;FROM ...&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;SpecOpsCourseRqmts:&lt;BR /&gt;LOAD&lt;BR /&gt; Station&lt;BR /&gt;,CourseCategory&lt;BR /&gt;,Required&lt;BR /&gt;...&lt;BR /&gt;FROM ...&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// then left join by station - creates too many rows&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LEFT JOIN (SpecOpsCourseRqmts)&lt;BR /&gt;LOAD&lt;BR /&gt; Station&lt;BR /&gt;,CourseTitle&lt;BR /&gt;RESIDENT CourseCompletion&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// then remove all rows that don't match your substring condition&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;INNER JOIN (SpecOpsCourseRqmts)&lt;BR /&gt;LOAD *&lt;BR /&gt;WHERE index(CourseTitle,SpecOpsCourseRqmts)&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// then left join onto your main table&lt;BR /&gt;// joins by both Sation AND CourseTitle&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LEFT JOIN (CourseCompletion)&lt;BR /&gt;LOAD *&lt;BR /&gt;RESIDENT SpecOpsCourseRqmts&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// no longer need SpecOpsCourseRqmts&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;DROP TABLE SpecOpsCourseRqmts;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Aug 2010 22:39:57 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2010-08-03T22:39:57Z</dc:date>
    <item>
      <title>Setting a field value in Load based on substring from separate table</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241125#M91576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two data sources - one is a relational DB and one is an Excel sheet. Here are the key fields from each:&lt;/P&gt;&lt;P&gt;CourseCompletion (DB table):&lt;BR /&gt;Station (string),&lt;BR /&gt;CourseTitle (string);&lt;/P&gt;&lt;P&gt;SpecOpsCourseRqmts (Excel Table):&lt;BR /&gt;Station (string),&lt;BR /&gt;CourseCategory (string),&lt;BR /&gt;Required (boolean);&lt;/P&gt;&lt;P&gt;Out of a long list of stations, 4 of them have unique requirements for which course categories they must complete. The requirements for those four stations are contained in the Excel file. What I need to accomplish sounds simple but has so far eluded me. In short I need to perform a left join where all records from the DB table are included, and those from the Excel table where the Station field matches the DB table, and (here's where it gets tricky) where the CourseCategory field in Excel is a substring of the CourseTitle field in the DB table.&lt;/P&gt;&lt;P&gt;If the Excel file was a table in the database I could do something like:&lt;BR /&gt;LOAD&lt;BR /&gt; Station,&lt;BR /&gt; CourseTitle,&lt;BR /&gt; Required;&lt;BR /&gt;SQL SELECT&lt;BR /&gt; CourseCompletion.Station,&lt;BR /&gt; Course.CourseTitle,&lt;BR /&gt; if(isnull(SpecOpsCourseRqmts.Required), 0, SpecOpsCourseRqmts.Required) as Required&lt;BR /&gt;FROM&lt;BR /&gt; CourseCompletion LEFT JOIN SpecOpsCourseRqmts ON&lt;BR /&gt; (CourseCompletion.Station = SpecOpsCourseRqmts.Station&lt;BR /&gt; AND CourseCompletion.CourseTitle LIKE '%' &amp;amp; SpecOpsCourseRqmts.CourseCategory &amp;amp; '%';&lt;BR /&gt;&lt;BR /&gt;Unfortunately they are not in the same database and I can't for the life of me figure out how to write the left join in the QV script.&lt;/P&gt;&lt;P&gt;Any help will be greatly appreciated!&lt;/P&gt;&lt;P&gt;Scott Moon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Aug 2010 17:48:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241125#M91576</guid>
      <dc:creator>smoon63</dc:creator>
      <dc:date>2010-08-03T17:48:11Z</dc:date>
    </item>
    <item>
      <title>Setting a field value in Load based on substring from separate table</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241126#M91577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There might be a simpler way, but I think this would work (untested):&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// load your raw data&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;CourseCompletion:&lt;BR /&gt;LOAD&lt;BR /&gt; Station&lt;BR /&gt;,CourseTitle&lt;BR /&gt;...&lt;BR /&gt;FROM ...&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;SpecOpsCourseRqmts:&lt;BR /&gt;LOAD&lt;BR /&gt; Station&lt;BR /&gt;,CourseCategory&lt;BR /&gt;,Required&lt;BR /&gt;...&lt;BR /&gt;FROM ...&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// then left join by station - creates too many rows&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LEFT JOIN (SpecOpsCourseRqmts)&lt;BR /&gt;LOAD&lt;BR /&gt; Station&lt;BR /&gt;,CourseTitle&lt;BR /&gt;RESIDENT CourseCompletion&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// then remove all rows that don't match your substring condition&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;INNER JOIN (SpecOpsCourseRqmts)&lt;BR /&gt;LOAD *&lt;BR /&gt;WHERE index(CourseTitle,SpecOpsCourseRqmts)&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// then left join onto your main table&lt;BR /&gt;// joins by both Sation AND CourseTitle&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LEFT JOIN (CourseCompletion)&lt;BR /&gt;LOAD *&lt;BR /&gt;RESIDENT SpecOpsCourseRqmts&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;// no longer need SpecOpsCourseRqmts&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;DROP TABLE SpecOpsCourseRqmts;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Aug 2010 22:39:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241126#M91577</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-08-03T22:39:57Z</dc:date>
    </item>
    <item>
      <title>Setting a field value in Load based on substring from separate table</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241127#M91578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply, John.&lt;/P&gt;&lt;P&gt;Couple of questions&lt;/P&gt;&lt;P&gt;- Should this be set up as one continuous LOAD statement, or with a series of temp tables culminating in one master table?&lt;/P&gt;&lt;P&gt;- Since CourseCompletion is the main table, should the original LEFT JOIN go the other direction - i.e. left join SpecOpsCourseRqmts to CourseCompletion?&lt;/P&gt;&lt;P&gt;- In the INNER JOIN to remove the the non-matching rows, should there be a source named? This is just a piece in the middle of a long and complicated script - I'm afraid doing a "LOAD *" without a specific source might wreak havoc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Aug 2010 15:48:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241127#M91578</guid>
      <dc:creator>smoon63</dc:creator>
      <dc:date>2010-08-04T15:48:51Z</dc:date>
    </item>
    <item>
      <title>Setting a field value in Load based on substring from separate table</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241128#M91579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason I didn't do the first left join in the other direction is that the inner join as I wrote it would then have removed a bunch of rows from the main table that you still wanted. That said, it probably would have been simpler and used less memory to do what you say, and just make a slightly more complicated inner join get what you wanted. It would probably just need one more line. For some reason, I didn't think to do it that way.&lt;/P&gt;&lt;P&gt;With that fixed, then yes, I think it would just be a series of load statements all into the same master table, rather than using a temp table like I did. That would be better.&lt;/P&gt;&lt;P&gt;Yes, the inner join should have a resident source named, SpecOpsCourseRqmts. That was just a mistake. Though if you change the original left join, then the source would be CourseCompletion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Aug 2010 17:41:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241128#M91579</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-08-04T17:41:44Z</dc:date>
    </item>
    <item>
      <title>Setting a field value in Load based on substring from separate table</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241129#M91580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;Meant to reply last week and got sidetracked. Your first solution turned out to be the winner. I had done something wrong the first time around and couldn't track it down, so I scrapped it and started over. Second time through it worked perfectly in pretty much the form you sent.&lt;/P&gt;&lt;P&gt;Thanks for another good save!&lt;/P&gt;&lt;P&gt;Scott Moon&lt;/P&gt;&lt;P&gt;Austin Fire Department&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Aug 2010 15:38:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-field-value-in-Load-based-on-substring-from-separate/m-p/241129#M91580</guid>
      <dc:creator>smoon63</dc:creator>
      <dc:date>2010-08-13T15:38:37Z</dc:date>
    </item>
  </channel>
</rss>

