<?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 Script : sum after join with a distinct clause give an incorrect result in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2009990#M83531</link>
    <description>&lt;P&gt;Hello all,&lt;BR /&gt;&lt;BR /&gt;I spent my evening on this issue :&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Here my small script to reproduce. Basically, I have a table, I join with another table with a left. No cartesian product, everything seems easy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TOTO:
load
1 as header_id,
1 as titi,
1 as qte_produit
Autogenerate(1);
Concatenate
LOAD
1 as header_id,
1 as titi,
3 as qte_produit
Autogenerate(1);
Concatenate
LOAD
1 as header_id,
1 as titi,
3 as qte_produit
Autogenerate(1);

NoConcatenate
totoche:
LOAD * RESIDENT TOTO;

left join(totoche)
LOAD distinct
1 as titi,
1 as tutu
Autogenerate(1);

drop field titi;

Drop table TOTO;

NoConcatenate
Bidule :
load header_id, sum(qte_produit) as rr RESIDENT totoche group by header_id;

drop table totoche;

Exit script;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The expected result is 7. The given result is 4.&lt;BR /&gt;&lt;BR /&gt;Can someone explain please ?&lt;/P&gt;
&lt;P&gt;Qlik Sense May 2022 Patch 6.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Simon&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 21:14:14 GMT</pubDate>
    <dc:creator>simonaubert</dc:creator>
    <dc:date>2022-11-28T21:14:14Z</dc:date>
    <item>
      <title>Script : sum after join with a distinct clause give an incorrect result</title>
      <link>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2009990#M83531</link>
      <description>&lt;P&gt;Hello all,&lt;BR /&gt;&lt;BR /&gt;I spent my evening on this issue :&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Here my small script to reproduce. Basically, I have a table, I join with another table with a left. No cartesian product, everything seems easy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TOTO:
load
1 as header_id,
1 as titi,
1 as qte_produit
Autogenerate(1);
Concatenate
LOAD
1 as header_id,
1 as titi,
3 as qte_produit
Autogenerate(1);
Concatenate
LOAD
1 as header_id,
1 as titi,
3 as qte_produit
Autogenerate(1);

NoConcatenate
totoche:
LOAD * RESIDENT TOTO;

left join(totoche)
LOAD distinct
1 as titi,
1 as tutu
Autogenerate(1);

drop field titi;

Drop table TOTO;

NoConcatenate
Bidule :
load header_id, sum(qte_produit) as rr RESIDENT totoche group by header_id;

drop table totoche;

Exit script;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The expected result is 7. The given result is 4.&lt;BR /&gt;&lt;BR /&gt;Can someone explain please ?&lt;/P&gt;
&lt;P&gt;Qlik Sense May 2022 Patch 6.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Simon&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 21:14:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2009990#M83531</guid>
      <dc:creator>simonaubert</dc:creator>
      <dc:date>2022-11-28T21:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Script : sum after join with a distinct clause give an incorrect result</title>
      <link>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2010055#M83536</link>
      <description>&lt;P&gt;Refer this article,&amp;nbsp;remove load distinct&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.qlikfix.com/2013/07/30/distinct-can-be-deceiving/" target="_blank"&gt;http://www.qlikfix.com/2013/07/30/distinct-can-be-deceiving/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;left join(totoche)&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;LOAD distinct&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;1 as titi,&lt;BR /&gt;1 as tutu&lt;BR /&gt;Autogenerate(1);&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 02:59:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2010055#M83536</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2022-11-29T02:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Script : sum after join with a distinct clause give an incorrect result</title>
      <link>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2010119#M83544</link>
      <description>&lt;P&gt;You expect this output for your totoche table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;header_id, titi, qte_produit, tutu&lt;/P&gt;
&lt;P&gt;1, 1, 3, 1&lt;/P&gt;
&lt;P&gt;1, 1, 3, 1&lt;/P&gt;
&lt;P&gt;1, 1, 1, 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;&amp;nbsp;pointed out, you where using distinct. Distinct will be applied on the whole output of your join and will therefore only include the 1,1,3,1 row once. Therefore the output will be.&lt;/P&gt;
&lt;P&gt;header_id, titi, qte_produit, tutu&lt;/P&gt;
&lt;P&gt;1, 1, 3, 1&lt;/P&gt;
&lt;P&gt;1, 1, 1, 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the sum of qte_produit will be 4 not 7.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 05:59:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2010119#M83544</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2022-11-29T05:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script : sum after join with a distinct clause give an incorrect result</title>
      <link>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2010129#M83545</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;&amp;nbsp; and thanks . In real life, I had duplicate in this step. And the workaround I found is to load a temp table with the distinct and then do the join. What I was looking for was why the hell it does not work.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Simon&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 06:18:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2010129#M83545</guid>
      <dc:creator>simonaubert</dc:creator>
      <dc:date>2022-11-29T06:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script : sum after join with a distinct clause give an incorrect result</title>
      <link>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2010133#M83546</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/25001"&gt;@Vegar&lt;/a&gt; . Thanks, that was the explanation I was looking for&lt;/P&gt;
&lt;P&gt;" Distinct will be applied on the whole output of your join "&lt;BR /&gt;&lt;BR /&gt;Damned, this is so unintuitive !&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Simon&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 06:20:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-sum-after-join-with-a-distinct-clause-give-an-incorrect/m-p/2010133#M83546</guid>
      <dc:creator>simonaubert</dc:creator>
      <dc:date>2022-11-29T06:20:34Z</dc:date>
    </item>
  </channel>
</rss>

