<?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: GROUP BY requires ALL fields? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381752#M702077</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're welcome, glad i could help &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Jonathan also mentions, SQL will also require to OR have the fields in the group by clause, OR use a aggregation function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Aug 2012 10:01:28 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-08-29T10:01:28Z</dc:date>
    <item>
      <title>GROUP BY requires ALL fields?</title>
      <link>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381748#M702073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to aggregate &lt;STRONG&gt;daily Sales for each Country.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13462312775596155" jivemacro_uid="_13462312775596155"&gt;load&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Quarter,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Month,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Week,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Day,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Country,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum(Sales)&lt;BR /&gt;resident SalesTable group by Date, Country;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the script results in an "Invalid expression" error message... apparently I have to list ALL used fields in the group by clause&lt;/P&gt;&lt;PRE _jivemacro_uid="_13462322105415878" jivemacro="quote"&gt;&lt;EM&gt;Qlikview Manual:&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;No other fields than the aggregation fields may be used outside aggregation functions in the loaded expressions.&lt;/EM&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I do so, it works. But in my opinion this is illogical: Why do I have to list Year, Quarter, Month, Week and Day in the group by clause although they don't affect the aggregation level (&lt;SPAN style="text-decoration: underline;"&gt;Date&lt;/SPAN&gt; = lowest level of detail)?!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my real application the group by clause would then consist of about 20 fields ... is there another way to avoid that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx for you suggestions!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 09:40:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381748#M702073</guid>
      <dc:creator>pennetzdorfer</dc:creator>
      <dc:date>2012-08-29T09:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: GROUP BY requires ALL fields?</title>
      <link>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381749#M702074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code jive-sql"&gt;load&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="jive-sql-object" style="color: navy; font-weight: bold;"&gt;Date&lt;/SPAN&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; only(&lt;SPAN class="jive-sql-object" style="color: navy; font-weight: bold;"&gt;Year)&lt;/SPAN&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;only(&lt;/SPAN&gt;Quarter&lt;SPAN style="color: #000080; font-family: monospace; font-weight: bold;"&gt;)&lt;/SPAN&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;only(&lt;/SPAN&gt;&lt;SPAN class="jive-sql-object" style="color: navy; font-weight: bold;"&gt;Month&lt;SPAN style="color: #000080; font-family: monospace; font-weight: bold;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;only(&lt;/SPAN&gt;Week&lt;SPAN style="color: #000080; font-family: monospace; font-weight: bold;"&gt;)&lt;/SPAN&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;only(&lt;/SPAN&gt;&lt;SPAN class="jive-sql-object" style="color: navy; font-weight: bold;"&gt;Day&lt;SPAN style="color: #000080; font-family: monospace; font-weight: bold;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Country,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="jive-sql-keyword" style="color: navy; font-weight: bold;"&gt;Sum&lt;/SPAN&gt;(Sales)&lt;BR /&gt;resident SalesTable &lt;SPAN class="jive-sql-keyword" style="color: navy; font-weight: bold;"&gt;group&lt;/SPAN&gt; &lt;SPAN class="jive-sql-keyword" style="color: navy; font-weight: bold;"&gt;by&lt;/SPAN&gt; &lt;SPAN class="jive-sql-object" style="color: navy; font-weight: bold;"&gt;Date&lt;/SPAN&gt;, Country;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You as a person does understand that the date column is the lowest level of detail, but as far as QlikView concerns, the other fields (such as year, etc) do not have to be relate to the date field. (QlikView does not know that each date can only have one year, etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also decide not to load the other fields, but just the date field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 09:51:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381749#M702074</guid>
      <dc:creator />
      <dc:date>2012-08-29T09:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: GROUP BY requires ALL fields?</title>
      <link>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381750#M702075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Florian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The load statement has no knowledge of the relationship between Date and Year/Quarter/Month/Week fields, so it would not know how to fulfill them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As in SQL with a Group By, the fields must be in either an aggregate expression or listed in the Group By clause. And no, there is no way round that. You could include them in the statement as aggregates like Max(Year) As Year, etc, but that is more work than simply listing the fields in the Group By. I just copy the field list from the Load to the Group By, and delete the aggregate fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example, because Year etc are indeed dependant on Date, including them in the Group By will not change the results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 09:56:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381750#M702075</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2012-08-29T09:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: GROUP BY requires ALL fields?</title>
      <link>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381751#M702076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey michelkr,&lt;/P&gt;&lt;P&gt;thank you, that makes sense!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 09:58:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381751#M702076</guid>
      <dc:creator>pennetzdorfer</dc:creator>
      <dc:date>2012-08-29T09:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: GROUP BY requires ALL fields?</title>
      <link>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381752#M702077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're welcome, glad i could help &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Jonathan also mentions, SQL will also require to OR have the fields in the group by clause, OR use a aggregation function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 10:01:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381752#M702077</guid>
      <dc:creator />
      <dc:date>2012-08-29T10:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: GROUP BY requires ALL fields?</title>
      <link>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381753#M702078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jonathan, thanks a lot for you explanations!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 10:43:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/GROUP-BY-requires-ALL-fields/m-p/381753#M702078</guid>
      <dc:creator>pennetzdorfer</dc:creator>
      <dc:date>2012-08-29T10:43:42Z</dc:date>
    </item>
  </channel>
</rss>

