<?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: Making a group by SUM() in the loading script per month in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Making-a-group-by-SUM-in-the-loading-script-per-month/m-p/463252#M172974</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dennis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use a group by clause and aggregation functions to get your sum of amounts per Month. Then use generic load and joins to create a crosstable from that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INPUT:&lt;/P&gt;&lt;P&gt;LOAD *, Date(Monthstart(Date),'YYYYMM') as Month;&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;chr(65+floor(RAND()*10)) as Product,&lt;/P&gt;&lt;P&gt;RAND()*100 as Value,&lt;/P&gt;&lt;P&gt;Date(MakeDate(2012)+floor(RAND()*366)) as Date&lt;/P&gt;&lt;P&gt;AutoGenerate 1000;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TMP:&lt;/P&gt;&lt;P&gt;Generic LOAD Product, 'Amount'&amp;amp;Month as Month, sum(Value) as SummedValue Resident INPUT Group by Product, Month;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;load distinct Product resident INPUT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table INPUT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR i = 0 to NoOfTables()&lt;/P&gt;&lt;P&gt;TableList:&lt;/P&gt;&lt;P&gt;LOAD TableName($(i)) as Tablename AUTOGENERATE 1&lt;/P&gt;&lt;P&gt;WHERE WildMatch(TableName($(i)), 'TMP.*');&lt;/P&gt;&lt;P&gt;NEXT i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR i = 1 to FieldValueCount('Tablename')&lt;/P&gt;&lt;P&gt;LET vTable = FieldValue('Tablename', $(i));&lt;/P&gt;&lt;P&gt;LEFT JOIN (Result) LOAD * RESIDENT $(vTable);&lt;/P&gt;&lt;P&gt;DROP TABLE $(vTable);&lt;/P&gt;&lt;P&gt;NEXT i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table TableList;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Oct 2012 16:29:52 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2012-10-29T16:29:52Z</dc:date>
    <item>
      <title>Making a group by SUM() in the loading script per month</title>
      <link>https://community.qlik.com/t5/QlikView/Making-a-group-by-SUM-in-the-loading-script-per-month/m-p/463251#M172973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to sum the field Amount per Month in the loading script.&lt;/P&gt;&lt;P&gt;For example I got these field&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Product&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Date&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;YearMonth (='YYYYMM' created from the field Date)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Amount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to SUM all the amounts per YearMonth, in the script.&lt;/P&gt;&lt;P&gt;This should create new fields with the total for every month that is loaded. (Amount201101, Amount201102, etc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How could I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dennis.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 15:59:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Making-a-group-by-SUM-in-the-loading-script-per-month/m-p/463251#M172973</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-29T15:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Making a group by SUM() in the loading script per month</title>
      <link>https://community.qlik.com/t5/QlikView/Making-a-group-by-SUM-in-the-loading-script-per-month/m-p/463252#M172974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dennis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use a group by clause and aggregation functions to get your sum of amounts per Month. Then use generic load and joins to create a crosstable from that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INPUT:&lt;/P&gt;&lt;P&gt;LOAD *, Date(Monthstart(Date),'YYYYMM') as Month;&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;chr(65+floor(RAND()*10)) as Product,&lt;/P&gt;&lt;P&gt;RAND()*100 as Value,&lt;/P&gt;&lt;P&gt;Date(MakeDate(2012)+floor(RAND()*366)) as Date&lt;/P&gt;&lt;P&gt;AutoGenerate 1000;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TMP:&lt;/P&gt;&lt;P&gt;Generic LOAD Product, 'Amount'&amp;amp;Month as Month, sum(Value) as SummedValue Resident INPUT Group by Product, Month;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;load distinct Product resident INPUT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table INPUT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR i = 0 to NoOfTables()&lt;/P&gt;&lt;P&gt;TableList:&lt;/P&gt;&lt;P&gt;LOAD TableName($(i)) as Tablename AUTOGENERATE 1&lt;/P&gt;&lt;P&gt;WHERE WildMatch(TableName($(i)), 'TMP.*');&lt;/P&gt;&lt;P&gt;NEXT i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR i = 1 to FieldValueCount('Tablename')&lt;/P&gt;&lt;P&gt;LET vTable = FieldValue('Tablename', $(i));&lt;/P&gt;&lt;P&gt;LEFT JOIN (Result) LOAD * RESIDENT $(vTable);&lt;/P&gt;&lt;P&gt;DROP TABLE $(vTable);&lt;/P&gt;&lt;P&gt;NEXT i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table TableList;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 16:29:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Making-a-group-by-SUM-in-the-loading-script-per-month/m-p/463252#M172974</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-10-29T16:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Making a group by SUM() in the loading script per month</title>
      <link>https://community.qlik.com/t5/QlikView/Making-a-group-by-SUM-in-the-loading-script-per-month/m-p/463253#M172975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am going to try that. Thaanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 21:30:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Making-a-group-by-SUM-in-the-loading-script-per-month/m-p/463253#M172975</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-29T21:30:54Z</dc:date>
    </item>
  </channel>
</rss>

