<?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: Formula from 2 fields in different tables in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362012#M493238</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Table2:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD * FROM Table2;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Table1:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;PricePaid,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ProductID,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if( PricePaid &amp;gt;= lookup('ContractPrice','ProductID',ProductID,'Table2') , 'Y', 'N') as PaidTooMuch,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM Table1;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So during the load of Table1, I lookup the ContractPrice in Table2 where ProductID of Table2 matches current ProductID in Table1 row. Table2 needs to be already loaded into QV (not necessarily all fields, but ProductID and ContractPrice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, if you only need these two columns from Table2, you could also do a mapping load of Table2 and use applymap() in your Table1 Load. The mapping table will not be part of your final data model, though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 May 2012 08:48:09 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2012-05-22T08:48:09Z</dc:date>
    <item>
      <title>Formula from 2 fields in different tables</title>
      <link>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362009#M493235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I have 2 tables, and want to do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(Table1.Field1&amp;nbsp; &amp;lt;= Table2.Field2, 'Yes', 'No') as NewField - where would I do this in the script?&amp;nbsp; And how do I reference fields from 2 different tables?&amp;nbsp; I'd like to be able to add this as a new field to Table1.&amp;nbsp; Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 May 2012 19:51:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362009#M493235</guid>
      <dc:creator>sspringer</dc:creator>
      <dc:date>2012-05-21T19:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Formula from 2 fields in different tables</title>
      <link>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362010#M493236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you want to compare these two fields record-wise (i.e. line 1 to line1 etc.) or how do you want to get unambiguous values for a comparison? Do you have another Key field? Then you can use lookup() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 May 2012 19:56:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362010#M493236</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-05-21T19:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Formula from 2 fields in different tables</title>
      <link>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362011#M493237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, there is a unique field across the 2 tables called ProductID.&amp;nbsp; I'm essentially looking in Table1 to see what was charged (PricePaid) and want to compare to Table2 (ContractPrice).&amp;nbsp; So, if Table1.PricePaid &amp;gt;= Table2.ContractPrice, then create a new field with "Y" or "N".&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 May 2012 22:52:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362011#M493237</guid>
      <dc:creator>sspringer</dc:creator>
      <dc:date>2012-05-21T22:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Formula from 2 fields in different tables</title>
      <link>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362012#M493238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Table2:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD * FROM Table2;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Table1:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;PricePaid,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ProductID,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if( PricePaid &amp;gt;= lookup('ContractPrice','ProductID',ProductID,'Table2') , 'Y', 'N') as PaidTooMuch,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM Table1;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So during the load of Table1, I lookup the ContractPrice in Table2 where ProductID of Table2 matches current ProductID in Table1 row. Table2 needs to be already loaded into QV (not necessarily all fields, but ProductID and ContractPrice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, if you only need these two columns from Table2, you could also do a mapping load of Table2 and use applymap() in your Table1 Load. The mapping table will not be part of your final data model, though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 08:48:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Formula-from-2-fields-in-different-tables/m-p/362012#M493238</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-05-22T08:48:09Z</dc:date>
    </item>
  </channel>
</rss>

