<?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 How to pass values from one loaded table as sql parameters to another in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-pass-values-from-one-loaded-table-as-sql-parameters-to/m-p/1590586#M596300</link>
    <description>&lt;P&gt;Hi. I'm trying to read data from two tables that share a common field, 'PartNo'. Both tables are massive and the only records I want to load are ones created today (usually not more than 100 records). The first table has a 'Date_created' field, so that's easy, but how do I load only the fields from the second table that match the first? If I try and load all the component records it takes too long. The script i've tried below gives the error:&lt;/P&gt;&lt;P&gt;"[Informix] A subquery has returned not exactly one row.&lt;BR /&gt;Components:&lt;BR /&gt;load Parent as PartNo, Component, Usage"&lt;/P&gt;&lt;P&gt;I just don't think my sql select on the second table is the right way to do it...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Note: The component_data table might have no matching parts or several.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---- Script ----&lt;BR /&gt;LET vToday = Date(Today(),'DD/MM/YYYY');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Parts:&lt;BR /&gt;load PartNo, Description, Date_created;&lt;BR /&gt;sql select * from part_data where Date_created = '$(vToday)';&lt;/P&gt;&lt;P&gt;Components:&lt;BR /&gt;load Parent as PartNo, Component, Usage;&lt;BR /&gt;sql select * from component_data&lt;BR /&gt;where Parent = (select distinct PartNo from part_data where Date_created = '$(vToday)')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 'Parts' load returns 33 records, and I would expect the 'Components' load (when working) would return about 50-60 records.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 03:20:09 GMT</pubDate>
    <dc:creator>jmclaren</dc:creator>
    <dc:date>2024-11-16T03:20:09Z</dc:date>
    <item>
      <title>How to pass values from one loaded table as sql parameters to another</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-pass-values-from-one-loaded-table-as-sql-parameters-to/m-p/1590586#M596300</link>
      <description>&lt;P&gt;Hi. I'm trying to read data from two tables that share a common field, 'PartNo'. Both tables are massive and the only records I want to load are ones created today (usually not more than 100 records). The first table has a 'Date_created' field, so that's easy, but how do I load only the fields from the second table that match the first? If I try and load all the component records it takes too long. The script i've tried below gives the error:&lt;/P&gt;&lt;P&gt;"[Informix] A subquery has returned not exactly one row.&lt;BR /&gt;Components:&lt;BR /&gt;load Parent as PartNo, Component, Usage"&lt;/P&gt;&lt;P&gt;I just don't think my sql select on the second table is the right way to do it...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Note: The component_data table might have no matching parts or several.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---- Script ----&lt;BR /&gt;LET vToday = Date(Today(),'DD/MM/YYYY');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Parts:&lt;BR /&gt;load PartNo, Description, Date_created;&lt;BR /&gt;sql select * from part_data where Date_created = '$(vToday)';&lt;/P&gt;&lt;P&gt;Components:&lt;BR /&gt;load Parent as PartNo, Component, Usage;&lt;BR /&gt;sql select * from component_data&lt;BR /&gt;where Parent = (select distinct PartNo from part_data where Date_created = '$(vToday)')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 'Parts' load returns 33 records, and I would expect the 'Components' load (when working) would return about 50-60 records.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 03:20:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-pass-values-from-one-loaded-table-as-sql-parameters-to/m-p/1590586#M596300</guid>
      <dc:creator>jmclaren</dc:creator>
      <dc:date>2024-11-16T03:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass values from one loaded table as sql parameters to another</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-pass-values-from-one-loaded-table-as-sql-parameters-to/m-p/1590926#M596301</link>
      <description>&lt;P&gt;You could try the following approach:&lt;/P&gt;&lt;P&gt;Parts:&lt;BR /&gt;load PartNo, Description, Date_created;&lt;BR /&gt;sql select * from part_data where Date_created = '$(vToday)';&lt;/P&gt;&lt;P&gt;FilterList: load distinct concat(PartNo, ',') as FilterList resident Parts:&lt;/P&gt;&lt;P&gt;let vFilterList = peek('FilterList', 0, 'FilterList');&lt;/P&gt;&lt;P&gt;Components:&lt;BR /&gt;load Parent as PartNo, Component, Usage;&lt;BR /&gt;sql select * from component_data&lt;BR /&gt;where Parent IN($(vFilterList))&lt;/P&gt;&lt;P&gt;If PartNo isn't numeric and/or your db requires any kind of quotes you need to add them during the concat() aggregation.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 11:25:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-pass-values-from-one-loaded-table-as-sql-parameters-to/m-p/1590926#M596301</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2019-06-12T11:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass values from one loaded table as sql parameters to another</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-pass-values-from-one-loaded-table-as-sql-parameters-to/m-p/1590962#M596302</link>
      <description>&lt;P&gt;Thank you so much Marcus - that's going to be extremely useful to know that technique. As you had suggested, the only change I had to make was to change my concat statement :&lt;/P&gt;&lt;P&gt;from:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;concat(PartNo, ',')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;to:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;concat(Chr(39)&amp;amp;PartNo&amp;amp;Chr(39), ',')&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 11:59:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-pass-values-from-one-loaded-table-as-sql-parameters-to/m-p/1590962#M596302</guid>
      <dc:creator>jmclaren</dc:creator>
      <dc:date>2019-06-12T11:59:13Z</dc:date>
    </item>
  </channel>
</rss>

