<?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 Is it possible to use AGGR inside a PICK Expression? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Is-it-possible-to-use-AGGR-inside-a-PICK-Expression/m-p/594018#M220105</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm updating an existing application that is using a detached table (columns are _KPI and Seq)&amp;nbsp; and a pick expression to combine several expressions into one expression.&amp;nbsp; It currently looks like below:&lt;/P&gt;&lt;P&gt;Dimensions:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;_KPI&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;TimeDrilldown&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;=pick(min({1} Seq),&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;num(sum([Metric1]), '#,##0'),&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;num(sum([Metric2]), '$#,##0;($#,##0)'),&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;num(sum([Metric3a]) / sum([Metric3b]), '#,##0.0%'),&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;...&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works fine.&amp;nbsp; However, I have some metrics that are more complicated than a simple aggregate - some values are point in time.&lt;/P&gt;&lt;P&gt;The data is loaded weekly, so I need the last week in whatever TimeDrilldown value is selected.&amp;nbsp; My solution was the following expression:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;num(FirstSortedValue(DISTINCT AGGR(SUM(Metric4),WeekOrder),-WeekOrder), '#,##0')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While this expression works fine as a separate expression, It doesn't seem to work inside the pick, it just returns a blank value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Will&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I was talking with a coworker and he made a comment that turned out to be correct.&amp;nbsp; _KPI, though irrelevant to the equation directly, was necessary to make the calculation work.&amp;nbsp; So the solution is:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;num(FirstSortedValue(DISTINCT AGGR(SUM(Metric4),_KPI,WeekOrder),-WeekOrder), '#,##0')&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;I tried adding the TimeDrilldown as well and it seemed to make no difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Will Ford&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Mar 2014 16:02:35 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-03-03T16:02:35Z</dc:date>
    <item>
      <title>Is it possible to use AGGR inside a PICK Expression?</title>
      <link>https://community.qlik.com/t5/QlikView/Is-it-possible-to-use-AGGR-inside-a-PICK-Expression/m-p/594018#M220105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm updating an existing application that is using a detached table (columns are _KPI and Seq)&amp;nbsp; and a pick expression to combine several expressions into one expression.&amp;nbsp; It currently looks like below:&lt;/P&gt;&lt;P&gt;Dimensions:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;_KPI&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;TimeDrilldown&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;=pick(min({1} Seq),&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;num(sum([Metric1]), '#,##0'),&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;num(sum([Metric2]), '$#,##0;($#,##0)'),&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;num(sum([Metric3a]) / sum([Metric3b]), '#,##0.0%'),&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;...&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works fine.&amp;nbsp; However, I have some metrics that are more complicated than a simple aggregate - some values are point in time.&lt;/P&gt;&lt;P&gt;The data is loaded weekly, so I need the last week in whatever TimeDrilldown value is selected.&amp;nbsp; My solution was the following expression:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;num(FirstSortedValue(DISTINCT AGGR(SUM(Metric4),WeekOrder),-WeekOrder), '#,##0')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While this expression works fine as a separate expression, It doesn't seem to work inside the pick, it just returns a blank value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Will&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I was talking with a coworker and he made a comment that turned out to be correct.&amp;nbsp; _KPI, though irrelevant to the equation directly, was necessary to make the calculation work.&amp;nbsp; So the solution is:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;num(FirstSortedValue(DISTINCT AGGR(SUM(Metric4),_KPI,WeekOrder),-WeekOrder), '#,##0')&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;I tried adding the TimeDrilldown as well and it seemed to make no difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Will Ford&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 16:02:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Is-it-possible-to-use-AGGR-inside-a-PICK-Expression/m-p/594018#M220105</guid>
      <dc:creator />
      <dc:date>2014-03-03T16:02:35Z</dc:date>
    </item>
  </channel>
</rss>

