<?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: Sum only grouped by one field? (Part 2) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354615#M1173529</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Revlin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using personal edition does not stop you posting a qvw file - I will still be able to read it as I have licensed copy of QV (as will many others who may also be able to help you).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once I see how to do what you are requesting, I can post the expression or script text here for you to try in your model.&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>Sun, 17 Jun 2012 17:46:06 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2012-06-17T17:46:06Z</dc:date>
    <item>
      <title>Sum only grouped by one field? (Part 2)</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354612#M1173526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I asked a question yesterday, which has been answered but I have an additional question that takes it that step further. I will repeat the first question then move on to my actual question: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First question:&lt;/P&gt;&lt;P&gt;Say I have a straight table with 4 fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;year,&lt;/P&gt;&lt;P&gt;quarter,&lt;/P&gt;&lt;P&gt;month,&lt;/P&gt;&lt;P&gt;quantity,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to add a 5th field which is an aggregate function but only grouped by the year, i.e. I want to add quanity_year which is the sum of quantity for the year. Can I do this using an expression?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example data below (for illustrative purposes):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table&lt;/P&gt;&lt;P&gt;year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quarter&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; month&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quantity&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year_quanity&lt;/P&gt;&lt;P&gt;2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&lt;/P&gt;&lt;P&gt;2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&lt;/P&gt;&lt;P&gt;2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14 &lt;/P&gt;&lt;P&gt;2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ANSWER: defining year_quantity as an expression defined as =sum(TOTAL &amp;lt;year&amp;gt; quantity). This works fine and achieve what I required as long as the year field is included in the straigh table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actual question:&lt;/P&gt;&lt;P&gt;Say I have the same data (as in table above) but this time I want to have a concatination of year and month as one field, then the sum of quantity. In other words, I want to remove the fields year, quarter, month and only have 3 fields, as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;year_month&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quantity&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year_quanity&lt;/P&gt;&lt;P&gt;2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&lt;/P&gt;&lt;P&gt;2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&lt;/P&gt;&lt;P&gt;2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14 &lt;/P&gt;&lt;P&gt;2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This however does not work as now the field year is not included in the straight table and the year_quantity expression stops working. The expression ends up giving me a total quanity over the whole dataset and does not factor in year at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas on how I can get the sum of quantity grouped by year but without actually including the year in the straight table? I know I could do this as a preporcessing step (say via sql) or via the load script but I was hoping to do this via an expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Revlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2012 10:27:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354612#M1173526</guid>
      <dc:creator />
      <dc:date>2012-06-15T10:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sum only grouped by one field? (Part 2)</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354613#M1173527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum(Aggr(Sum(If(Left(year_month, 4) = year, quantity)), year, year_month)) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(You might not need year_month as the second parameter to the Aggr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that does not work, I suggest that you post a sample so that we can see how to do this with your data model.&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>Fri, 15 Jun 2012 11:14:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354613#M1173527</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2012-06-15T11:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sum only grouped by one field? (Part 2)</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354614#M1173528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonathan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry that expression does not work. Also, cannot attach a qliview file as I am using the tril/personal edition which means I can only use local files created on my own version of qlikview.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2012 12:24:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354614#M1173528</guid>
      <dc:creator />
      <dc:date>2012-06-15T12:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sum only grouped by one field? (Part 2)</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354615#M1173529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Revlin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using personal edition does not stop you posting a qvw file - I will still be able to read it as I have licensed copy of QV (as will many others who may also be able to help you).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once I see how to do what you are requesting, I can post the expression or script text here for you to try in your model.&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>Sun, 17 Jun 2012 17:46:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354615#M1173529</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2012-06-17T17:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sum only grouped by one field? (Part 2)</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354616#M1173530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls. have a look at the attached file.&lt;/P&gt;&lt;P&gt;I only hid the dimensions from presentation tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="loading" href="http://quickdevtips.blogspot.com/" title="http://quickdevtips.blogspot.com/"&gt;http://quickdevtips.blogspot.com/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jun 2012 20:20:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354616#M1173530</guid>
      <dc:creator />
      <dc:date>2012-06-17T20:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sum only grouped by one field? (Part 2)</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354617#M1173531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonathan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ok - please see attached Qlikview file. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Revlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 20:35:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354617#M1173531</guid>
      <dc:creator />
      <dc:date>2012-06-18T20:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sum only grouped by one field? (Part 2)</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354618#M1173532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Couldn't attach the file to the reply so had to attach it to the question above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2012 16:06:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-only-grouped-by-one-field-Part-2/m-p/354618#M1173532</guid>
      <dc:creator />
      <dc:date>2012-06-19T16:06:46Z</dc:date>
    </item>
  </channel>
</rss>

