<?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 Make a SUM() after a subquery with distinct in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Make-a-SUM-after-a-subquery-with-distinct/m-p/1924216#M1218699</link>
    <description>&lt;P&gt;Hello.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had this up to now:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if(GetSelectedCount(n_year)=1,Round(sum({name_month} distinct cost_total),0.01),' ')&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(where &lt;EM&gt;n_year&lt;/EM&gt;, &lt;EM&gt;name_month&lt;/EM&gt; are filters selected)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It worked pretty fine until I saw that&amp;nbsp;&lt;EM&gt;cost_total&lt;/EM&gt; can be repeated! so I need the field &lt;EM&gt;id_pr&amp;nbsp;&lt;/EM&gt; to separate them.&lt;/P&gt;
&lt;P&gt;The solution in query is easy to see:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SELECT SUM(cost_total) FROM (SELECT DISTINCT id_pr, cost_total FROM facts_table WHERE... [filters i have in my dashboard])&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Can anybody help me, please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 18:46:34 GMT</pubDate>
    <dc:creator>CarAlAg</dc:creator>
    <dc:date>2022-04-28T18:46:34Z</dc:date>
    <item>
      <title>Make a SUM() after a subquery with distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Make-a-SUM-after-a-subquery-with-distinct/m-p/1924216#M1218699</link>
      <description>&lt;P&gt;Hello.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had this up to now:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if(GetSelectedCount(n_year)=1,Round(sum({name_month} distinct cost_total),0.01),' ')&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(where &lt;EM&gt;n_year&lt;/EM&gt;, &lt;EM&gt;name_month&lt;/EM&gt; are filters selected)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It worked pretty fine until I saw that&amp;nbsp;&lt;EM&gt;cost_total&lt;/EM&gt; can be repeated! so I need the field &lt;EM&gt;id_pr&amp;nbsp;&lt;/EM&gt; to separate them.&lt;/P&gt;
&lt;P&gt;The solution in query is easy to see:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SELECT SUM(cost_total) FROM (SELECT DISTINCT id_pr, cost_total FROM facts_table WHERE... [filters i have in my dashboard])&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Can anybody help me, please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 18:46:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Make-a-SUM-after-a-subquery-with-distinct/m-p/1924216#M1218699</guid>
      <dc:creator>CarAlAg</dc:creator>
      <dc:date>2022-04-28T18:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Make a SUM() after a subquery with distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Make-a-SUM-after-a-subquery-with-distinct/m-p/1924264#M1218701</link>
      <description>&lt;P&gt;The Qlik expression analog to a sub select is Aggr(). So something like:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Sum(Aggr(Only(cost_total)), id_pr))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;-Rob&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 21:04:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Make-a-SUM-after-a-subquery-with-distinct/m-p/1924264#M1218701</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2022-04-28T21:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Make a SUM() after a subquery with distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Make-a-SUM-after-a-subquery-with-distinct/m-p/1929768#M1218924</link>
      <description>&lt;P&gt;THX Rob!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the end, I wasn't putting all the proper condition in the group by. You helped me focusing in solving the query I already had almost complete. I was in a point where I was trying some weird stuff&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 11:29:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Make-a-SUM-after-a-subquery-with-distinct/m-p/1929768#M1218924</guid>
      <dc:creator>CarAlAg</dc:creator>
      <dc:date>2022-05-12T11:29:32Z</dc:date>
    </item>
  </channel>
</rss>

