<?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 Aggr() function - Usage of CPU Cores in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933130#M958709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having a calculated Dimension, wherein I am using Aggr() function. Overall Data size is around 200M records. Systme configuration is 16 Cores, 128GB RAM. I think memory &amp;amp; cpu is not an issue. It is about utilization of resource.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To populate the chart (straight tale), qv is taking almost 120secs. I cross checked at resource utilization, only few of cores being used while calculating the chart dimension. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What could be the reason ? How to optimize the aggr() function ? Below is the calculated dimension. All the fields being used are from a single table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if((aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id))=0,'No Purchase',&lt;/P&gt;&lt;P&gt;if((aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id))&amp;lt;vLowerAmtLimit,'&amp;lt; '&amp;amp;vLowerAmtLimit,&lt;/P&gt;&lt;P&gt;if((aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id))&amp;lt;vUpperAmtLimit,vLowerAmtLimit&amp;amp; ' - '&amp;amp;vUpperAmtLimit,&lt;/P&gt;&lt;P&gt;if((aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id))&amp;gt;=vUpperAmtLimit,'&amp;gt;='&amp;amp;vUpperAmtLimit))))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Nov 2015 09:01:45 GMT</pubDate>
    <dc:creator>manojkulkarni</dc:creator>
    <dc:date>2015-11-04T09:01:45Z</dc:date>
    <item>
      <title>Aggr() function - Usage of CPU Cores</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933130#M958709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having a calculated Dimension, wherein I am using Aggr() function. Overall Data size is around 200M records. Systme configuration is 16 Cores, 128GB RAM. I think memory &amp;amp; cpu is not an issue. It is about utilization of resource.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To populate the chart (straight tale), qv is taking almost 120secs. I cross checked at resource utilization, only few of cores being used while calculating the chart dimension. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What could be the reason ? How to optimize the aggr() function ? Below is the calculated dimension. All the fields being used are from a single table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if((aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id))=0,'No Purchase',&lt;/P&gt;&lt;P&gt;if((aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id))&amp;lt;vLowerAmtLimit,'&amp;lt; '&amp;amp;vLowerAmtLimit,&lt;/P&gt;&lt;P&gt;if((aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id))&amp;lt;vUpperAmtLimit,vLowerAmtLimit&amp;amp; ' - '&amp;amp;vUpperAmtLimit,&lt;/P&gt;&lt;P&gt;if((aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id))&amp;gt;=vUpperAmtLimit,'&amp;gt;='&amp;amp;vUpperAmtLimit))))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 09:01:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933130#M958709</guid>
      <dc:creator>manojkulkarni</dc:creator>
      <dc:date>2015-11-04T09:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr() function - Usage of CPU Cores</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933131#M958710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;have you tried moving this calculation in Expression instead of Calculated dimension?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 09:15:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933131#M958710</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2015-11-04T09:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr() function - Usage of CPU Cores</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933132#M958711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Manoj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the P() can be used. can you please try with the same?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Punit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 09:29:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933132#M958711</guid>
      <dc:creator>punitpopli</dc:creator>
      <dc:date>2015-11-04T09:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr() function - Usage of CPU Cores</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933133#M958712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your nested if-loop with aggr-functions is a first class performance-killer. Even if aggr could be excuted in multi-threading it would be need a lot of ressources and response quite slowly by large datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A quite easier approach might be to use the class() function to create (variable) buckets - it's not excactly the same what do you doing now but the insights which the user could get is quite similar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is really no option than you need to reduce the number of calculations within your expression and each possible complexity. This could be reached with a kind of lookup-function which takes the result from the aggr-part (which needs to be calculate only once) and returned the lookup-value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have done similar things before and think this method could be adapted even if your checking against variables is more complicated: &lt;A href="https://community.qlik.com/message/593232"&gt;Re: Substitute to nested ifs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And in your case a solution might be built in this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pick(match(&lt;/P&gt;&lt;P&gt;ceil(aggr(sum({&amp;lt;Year=,Month=, user_txn_date = {"&amp;gt;=v_m12_date2&amp;lt;=vSelectedMonthDatePrevious"}&amp;gt;} bill_amount),user_id)),&lt;/P&gt;&lt;P&gt;&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; 0,1,2,3,4 ......),&lt;/P&gt;&lt;P&gt;'no Purchase', $(=repeat('&amp;lt; ' &amp;amp; vLowerAmtLimit, vLowerAmtLimit)), ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Challanges are to find an appropriate rounding-algorithm which will be needed for the lookup-matching and for the repeating-function inside the $-sign expansion - to create such lists with a correct syntax isn't easy and will need some attempts. If your limit-variables aren't complete variable - maybe restricted with a drop-down list, it could be easier to use fixed lookup-lists which are choosen through the limit-variables, too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further I have your inner if-checking replaced with a set analysis syntax - to mix up both if and set analysis is possible but most not necessary and set analysis will be mostly (a lot) faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 10:44:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933133#M958712</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-11-04T10:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr() function - Usage of CPU Cores</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933134#M958713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;STRONG style="font-size: 11.7px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;A href="https://community.qlik.com/people/Marcus_Sommer"&gt;Marcus_Sommer&lt;/A&gt;, &lt;/STRONG&gt;for your suggestion. it makes sense. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Didn't understand the functionality of '$(=repeat' in your expression. Please could you elaborate more. How to interpret in the above condition ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 12:31:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933134#M958713</guid>
      <dc:creator>manojkulkarni</dc:creator>
      <dc:date>2015-11-04T12:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr() function - Usage of CPU Cores</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933135#M958714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Repeat('string', 'number') repeats a string as often as defined within the second parameter ('number'). In your case with a pick(match()) - lookup you don't know how many times you need which string-return to place in because of the use from the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example (simplified) with variable-values and how the loopup return-list needs to look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var: vLowerAmtLimit = 2&lt;/P&gt;&lt;P&gt;var: vUpperAmtLimit = 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pick(match(Expression, 0,1,2,3,4,5,6,7,8),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'no Purchse', '&amp;lt; vLower', 'vLower - vUpper', 'vLower - vUpper', 'vUpper', '&amp;gt; vUpper', '&amp;gt; vUpper', '&amp;gt; vUpper')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The $-sign expansion $(=Expression) will be needed because no expression would be directly accepted as parameter to pick(match()) so it needs to be calculated before - see here how it worked: &lt;A href="https://community.qlik.com/qlik-blogpost/3444"&gt;The Magic of Dollar Expansions&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 13:21:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933135#M958714</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-11-04T13:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr() function - Usage of CPU Cores</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933136#M958715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried with below changes, but results are not correct. Whats wrong with this ? When I replaced if condition with set analysis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aggr(sum({$&amp;lt;Year=, Month=,user_txn_date={"&amp;gt;=$(v_m12_date2) &amp;lt;=$(vSelectedMonthDatePrevious) "}&amp;gt;} ((bill_amount))),user_id)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 09:39:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933136#M958715</guid>
      <dc:creator>manojkulkarni</dc:creator>
      <dc:date>2015-11-05T09:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr() function - Usage of CPU Cores</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933137#M958716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason could be that your variables returned (beside their values) another format and by set analysis must be also the format identically. For example would be a check on user_txn_date from 11/05/2015 = 42313 not match within set analysis but within an if-loop it does. If this happens you need an additionally date-formatting like date(42313, 'MM/DD'YYYY'). &lt;/P&gt;&lt;P&gt;Further if the variable contained a string you would need single-quotes around it to access the variable properly - this meant if the variable contained this value: 11/05/2015 you would need: '$(var)'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To check what you get I suggest you used a further chart with user_id as dimension and used those parts from the calculated dimension as a normal expression but used no labels for them. Within the label you could now see how qv interpreted the expression and could then adjust it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(aggr(sum({&amp;lt;Year=,Month=, user_txn_date = {"&amp;gt;=v_m12_date2&amp;lt;=vSelectedMonthDatePrevious"}&amp;gt;} bill_amount),user_id)) // new version&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(aggr(sum({&amp;lt;Year=,Month=&amp;gt;}if (user_txn_date&amp;gt;=(v_m12_date2) AND user_txn_date&amp;lt;= (vSelectedMonthDatePrevious),bill_amount)),user_id)) // your original version&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 10:36:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-Usage-of-CPU-Cores/m-p/933137#M958716</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-11-05T10:36:02Z</dc:date>
    </item>
  </channel>
</rss>

