<?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 Aggregate values table in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239679#M90280</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I would rather do this in the load script using flags. So on every Task row there's a flag Done or Not Done (I could change this to say Open or Closed or the like). I want to then evaluate, for every Category value, does there exist a Task that's Open. For the other field, I'd want to evaluate if there exists a Task that's Closed. What do you think?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Feb 2010 23:39:37 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-02-16T23:39:37Z</dc:date>
    <item>
      <title>Aggregate values table</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239677#M90278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys. I'm trying to create a table of aggregate values and I was wondering if you guys had an elegant solution.&lt;/P&gt;&lt;P&gt;I have one table called Tasks. Each task row has a Category field, and a Completed field with values Done or Not Done.&lt;/P&gt;&lt;P&gt;I want to create a derived Categories table that pulls out all the values of the Category field in the Tasks table. This table will obviously link to the Tasks table by the Category name. I want to then create two derived fields.&lt;/P&gt;&lt;P&gt;One field will be called HasCompletedTask, and will evaluate to true if there exists at least one Task row where Completed is Done. Otherwise, false.&lt;/P&gt;&lt;P&gt;The other derived field will be called AllTasksCompleted, and will evaluate to true if ALL task rows of that category are Done. Otherwise, false.&lt;/P&gt;&lt;P&gt;Any ideas? Please let me know if you have any questions. Thank you for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2010 22:50:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239677#M90278</guid>
      <dc:creator />
      <dc:date>2010-02-16T22:50:29Z</dc:date>
    </item>
    <item>
      <title>Aggregate values table</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239678#M90279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is probably easier and better to handle this in your Load using flags.&lt;/P&gt;&lt;P&gt;If you want to do it using Expressions, then you'll probably need the Concat() function. This should get you a comma separated list of all Completed values for that respective Category:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Concat(TOTAL &amp;lt;Categories&amp;gt; Completed)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;The All Completed field will be easier than the Has Completed, because Done is a substring in Not Done. For the All Completed, try:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Index(Concat(TOTAL &amp;lt;Categories&amp;gt; Completed), 'Not')=0&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I'm not sure of a great way to to the Has Completed. You need to search for Done, but not within a Not Done string.&lt;/P&gt;&lt;P&gt;EDIT: I guess you could try:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Index(Concat(TOTAL &amp;lt;Categories&amp;gt; Completed), ',Done')&amp;gt;0 or&lt;BR /&gt;Left(Concat(TOTAL &amp;lt;Categories&amp;gt; Completed), 4) = 'Done'&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;But that's nowhere near elegant. &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2010 23:00:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239678#M90279</guid>
      <dc:creator />
      <dc:date>2010-02-16T23:00:47Z</dc:date>
    </item>
    <item>
      <title>Aggregate values table</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239679#M90280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I would rather do this in the load script using flags. So on every Task row there's a flag Done or Not Done (I could change this to say Open or Closed or the like). I want to then evaluate, for every Category value, does there exist a Task that's Open. For the other field, I'd want to evaluate if there exists a Task that's Closed. What do you think?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2010 23:39:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239679#M90280</guid>
      <dc:creator />
      <dc:date>2010-02-16T23:39:37Z</dc:date>
    </item>
    <item>
      <title>Aggregate values table</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239680#M90281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the source of your data? Are you pulling from QVDs or using SQL to pull directly from a database?&lt;/P&gt;&lt;P&gt;I always seem to think of the SQL method first, because I've been using that longer. It would be something like this (Oracle syntax):&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;SELECT Tasks.*, Has.HasComp, All.AllComp FROM Tasks,&lt;BR /&gt;(SELECT Category, Max(Completed) As HasComp FROM Tasks&lt;BR /&gt; WHERE Completed = 'Done' GROUP BY Category) Has,&lt;BR /&gt;(SELECT Category, Max(Completed) As AllComp FROM Tasks&lt;BR /&gt; WHERE Completed = 'Not Done' GROUP BY Category) All&lt;BR /&gt;WHERE Tasks.Category = Has.Category (+)&lt;BR /&gt; AND Tasks.Category = All.Category (+)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Something like that. You would end up modifying the select to return 0 for HasComp if it is null and 1 if not. And the same thing for AllComp.&lt;/P&gt;&lt;P&gt;I'm sure you could also handle this using QlikView Load syntax.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2010 16:05:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239680#M90281</guid>
      <dc:creator />
      <dc:date>2010-02-17T16:05:56Z</dc:date>
    </item>
    <item>
      <title>Aggregate values table</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239681#M90282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to set up a load using an Inline to create some test data. It's kind of long and probably inefficient. I'll also try to upload the sample file, but that functionality hasn't been working on the forum.&lt;/P&gt;&lt;P&gt;Load:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;DataLoad:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt; Task,Category,Completed&lt;BR /&gt; A,Cat1,Done&lt;BR /&gt; B,Cat2,Not Done&lt;BR /&gt; C,Cat1,Not Done&lt;BR /&gt; D,Cat2,Not Done&lt;BR /&gt; E,Cat3,Done&lt;BR /&gt; F,Cat3,Done&lt;BR /&gt;];&lt;BR /&gt;AllComp:&lt;BR /&gt;LOAD Category, Sum(0) As AllC&lt;BR /&gt;RESIDENT DataLoad&lt;BR /&gt;WHERE Completed = 'Not Done'&lt;BR /&gt;GROUP BY Category;&lt;BR /&gt;HasComp:&lt;BR /&gt;LOAD Category, Max(1) As HasC&lt;BR /&gt;RESIDENT DataLoad&lt;BR /&gt;WHERE Completed = 'Done'&lt;BR /&gt;GROUP BY Category;&lt;BR /&gt;DataInt:&lt;BR /&gt;LOAD Task As Task1, Category As Cat1,Completed As Comp1 RESIDENT DataLoad;&lt;BR /&gt;LEFT JOIN LOAD Category As Cat1, AllC RESIDENT AllComp;&lt;BR /&gt;LEFT JOIN LOAD Category As Cat1, HasC RESIDENT HasComp;&lt;BR /&gt;DROP TABLE DataLoad;&lt;BR /&gt;DROP TABLE AllComp;&lt;BR /&gt;DROP TABLE HasComp;&lt;BR /&gt;Data:&lt;BR /&gt;LOAD Task1 As Task, Cat1 As Category, Comp1 As Completed,&lt;BR /&gt;if(AllC &amp;lt;&amp;gt; 0, 1, AllC) As AllComplete, if(HasC &amp;lt;&amp;gt; 1, 0, HasC) As HasComplete&lt;BR /&gt;RESIDENT DataInt;&lt;BR /&gt;DROP TABLE DataInt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2010 16:34:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239681#M90282</guid>
      <dc:creator />
      <dc:date>2010-02-17T16:34:59Z</dc:date>
    </item>
    <item>
      <title>Aggregate values table</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239682#M90283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could do a load of the initial table, then do a distinct load of just the status field in a temp table basically leaving you either one or two values in a single field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, in the example data very kindly provided by NMiller, it would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataLoad:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;Task,Category,Completed&lt;/P&gt;&lt;P&gt;A,Cat1,Done&lt;/P&gt;&lt;P&gt;B,Cat2,Not Done&lt;/P&gt;&lt;P&gt;C,Cat1,Not Done&lt;/P&gt;&lt;P&gt;D,Cat2,Not Done&lt;/P&gt;&lt;P&gt;E,Cat3,Done&lt;/P&gt;&lt;P&gt;F,Cat3,Done&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CompletedIndexTemp:&lt;/P&gt;&lt;P&gt;LOAD DISTINCT Completed&lt;/P&gt;&lt;P&gt;RESIDENT DataLoad;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From here, I would use a peek in a variable to determine if 'Not Done' exists, and return text based on the result. My preference is always to use a variable for these kinds of things, but this could easily be done in another table as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET CompletedFlag = If(peek('Completed', 0, 'CompletedIndexTemp') = 'Not Done' OR peek('Completed', 1, 'CompletedIndexTemp') = 'Not Done', 'Not Done', 'Done');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2010 17:08:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-values-table/m-p/239682#M90283</guid>
      <dc:creator />
      <dc:date>2010-02-17T17:08:22Z</dc:date>
    </item>
  </channel>
</rss>

