<?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 do a calculation in the script between 2 fields from 2 diff tables? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238653#M716499</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my experience, when a join is creating rows that it shouldn't be creating, it's been because one of the tables has extra rows that I wasn't expecting. So I might have more than one row for some of the join key values in one of the tables. To look for the presence of "duplicate" rows, just do a table with A as the dimension, count(A) as the expression, and sort descending. If you see any values more than 1, you know you have duplicate rows for those values of A. Figuring out where they came from then involves adding additional fields to the table until you find a field that causes more than one row to appear for a single value of A. Sometimes, you can add ALL of your fields and it will never create more than one row. In that case, you really DO have duplicates. You can see them by doing a load from your original table to a new temp table, include new field recno() as ID, dropping the old table, and adding ID to your chart. That still doesn't necessarily tell you how they appeared, but it may be useful information.&lt;/P&gt;&lt;P&gt;Assuming you solve your too many rows problem, I try to avoid loading one table from another and dropping the first, because I suspect it uses, well, double the memory for that table. I don't have a ton of memory to toss around. So I'd add on the new field with a left join:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;myTable:&lt;BR /&gt;Load A, B, C From T1;&lt;BR /&gt;INNER JOIN Load A, D, E From T2;&lt;BR /&gt;&lt;STRONG&gt;LEFT JOIN Load A, C*E as Something&lt;BR /&gt;RESIDENT myTable;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Feb 2010 02:07:06 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2010-02-17T02:07:06Z</dc:date>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238645#M716491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;I have 2 tables:&lt;/P&gt;&lt;P&gt;Table T1:&lt;BR /&gt;Columns: A, B and C&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table T2:&lt;BR /&gt;Columns A, D and E&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The link between T1 and T2 is made by column A.&lt;/P&gt;&lt;P&gt;I need in the script to join both tables in one single logic table and also calculate the result of C * E.&lt;/P&gt;&lt;P&gt;Join the tables is easy, I am doing this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;myTable:&lt;BR /&gt;Load A, B, C From T1;&lt;BR /&gt;INNER JOIN Load A, D, E From T2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, how to calculate C * E?&lt;BR /&gt;&lt;BR /&gt;If I try this:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;myTable:&lt;BR /&gt;Load *, C * E;&lt;BR /&gt;Load A, B, C From T1;&lt;BR /&gt;INNER JOIN Load A, D, E From T2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It says column E is unknown because the preceding load does not read T2. So, how can I do what I need to do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Feb 2010 02:23:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238645#M716491</guid>
      <dc:creator />
      <dc:date>2010-02-14T02:23:30Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238646#M716492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;you can do somthing like that&lt;/P&gt;&lt;P&gt;myTableTemp:&lt;BR /&gt;Load A, B, C From T1;&lt;BR /&gt;INNER JOIN Load A, D, E From T2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;myTable:&lt;/P&gt;&lt;P&gt;load * ,&lt;/P&gt;&lt;P&gt;E*c as result&lt;/P&gt;&lt;P&gt;resident myTableTemp;&lt;/P&gt;&lt;P&gt;drop table myTableTemp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Feb 2010 08:58:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238646#M716492</guid>
      <dc:creator>lironbaram</dc:creator>
      <dc:date>2010-02-14T08:58:38Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238647#M716493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Humm, I've tried that but when I do, for some reason the result table has double records. The table in the DB has only about 400 records, the 1st table has that number of records but the second one adds those records twice. Any thought?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Feb 2010 12:46:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238647#M716493</guid>
      <dc:creator />
      <dc:date>2010-02-14T12:46:08Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238648#M716494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;did you drop the originals tables in the end of the load script&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Feb 2010 13:02:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238648#M716494</guid>
      <dc:creator>lironbaram</dc:creator>
      <dc:date>2010-02-14T13:02:20Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238649#M716495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I already asked approximatly the same question :&lt;/P&gt;&lt;P&gt;http://community.qlik.com/forums/p/25501/97365.aspx#97365&lt;/P&gt;&lt;P&gt;I have implemented John's answer.&lt;/P&gt;&lt;P&gt;It should also be suitable for your data&lt;/P&gt;&lt;P&gt;Pierre.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Feb 2010 14:51:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238649#M716495</guid>
      <dc:creator>pdumas</dc:creator>
      <dc:date>2010-02-14T14:51:32Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238650#M716496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Humm, I've tried that but when I do, for some reason the result table has double records. The table in the DB has only about 400 records, the 1st table has that number of records but the second one adds those records twice. Any thought?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Feb 2010 00:08:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238650#M716496</guid>
      <dc:creator />
      <dc:date>2010-02-15T00:08:37Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238651#M716497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Humm, I've tried that but when I do, for some reason the result table has double records. The table in the DB has only about 400 records, the 1st table has that number of records but the second one adds those records twice. Any thought?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Feb 2010 00:25:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238651#M716497</guid>
      <dc:creator />
      <dc:date>2010-02-15T00:25:53Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238652#M716498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone have any thought why when I do a Load Resident from an existing table, the result table has more then double records? How can I prevent that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Feb 2010 01:27:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238652#M716498</guid>
      <dc:creator />
      <dc:date>2010-02-15T01:27:16Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238653#M716499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my experience, when a join is creating rows that it shouldn't be creating, it's been because one of the tables has extra rows that I wasn't expecting. So I might have more than one row for some of the join key values in one of the tables. To look for the presence of "duplicate" rows, just do a table with A as the dimension, count(A) as the expression, and sort descending. If you see any values more than 1, you know you have duplicate rows for those values of A. Figuring out where they came from then involves adding additional fields to the table until you find a field that causes more than one row to appear for a single value of A. Sometimes, you can add ALL of your fields and it will never create more than one row. In that case, you really DO have duplicates. You can see them by doing a load from your original table to a new temp table, include new field recno() as ID, dropping the old table, and adding ID to your chart. That still doesn't necessarily tell you how they appeared, but it may be useful information.&lt;/P&gt;&lt;P&gt;Assuming you solve your too many rows problem, I try to avoid loading one table from another and dropping the first, because I suspect it uses, well, double the memory for that table. I don't have a ton of memory to toss around. So I'd add on the new field with a left join:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;myTable:&lt;BR /&gt;Load A, B, C From T1;&lt;BR /&gt;INNER JOIN Load A, D, E From T2;&lt;BR /&gt;&lt;STRONG&gt;LEFT JOIN Load A, C*E as Something&lt;BR /&gt;RESIDENT myTable;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2010 02:07:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238653#M716499</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-02-17T02:07:06Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238654#M716500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suspect that when you do a resident load resulting in double the rows, you get an automatic concatenation at some point. Maybe you're doing a resident load without changing any fieldnames from the original table?&lt;/P&gt;&lt;P&gt;Try pasting the current load script here and we'll help you look at what the problem might be.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2010 07:19:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238654#M716500</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-02-17T07:19:41Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238655#M716501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am adding a new column in the load resident, so I don't know why is concatenating.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2010 13:48:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238655#M716501</guid>
      <dc:creator />
      <dc:date>2010-02-17T13:48:17Z</dc:date>
    </item>
    <item>
      <title>How to do a calculation in the script between 2 fields from 2 diff tables?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238656#M716502</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;Why dont you do this&lt;/P&gt;&lt;P&gt;Table:&lt;/P&gt;&lt;P&gt;LOAD A, B, C FROM T1&lt;/P&gt;&lt;P&gt;Concatenate (Table)&lt;/P&gt;&lt;P&gt;LOAD A, D, E FROM T2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in the Interface use the expression SUM(B) - SUM(D)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively if the calculations have to be done in the script do the concatenate in the script as a temporary table, then doing a resident load from that and use a group by function will manipulate the data accordingly.&lt;/P&gt;&lt;P&gt;Then add a preceding load taking one field away from the other field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is of help,&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2010 14:14:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-a-calculation-in-the-script-between-2-fields-from-2/m-p/238656#M716502</guid>
      <dc:creator />
      <dc:date>2010-02-17T14:14:32Z</dc:date>
    </item>
  </channel>
</rss>

