<?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: Use of variables in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445728#M433266</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An alternative (local to a single object) approach could be to create a hidden column containing expression Count(Distinct x), naming it (use the label field for that) and referring to that expression label in all other visible expression columns except the last one. Let's say you called that column CntDistX, then the others would get the following expressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column 1 (hidden): &lt;SPAN style="font-family: 'courier new', courier;"&gt;Count(DISTINCT x) // Called 'CntDistX'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Column 2: &lt;SPAN style="font-family: 'courier new', courier;"&gt;CntDistX - 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;Column 3: &lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'courier new', courier;"&gt;CntDistX&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; * 2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;Column 4: &lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'courier new', courier;"&gt;CntDistX&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; * 10.5 // constants use US separators&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;Column 5: &lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'courier new', courier;"&gt;CntDistX&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; / 320&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Column 6: &lt;SPAN style="font-family: 'courier new', courier;"&gt;Count( x )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;This is easy to create and you will detect any performance improvements immediately.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Aug 2017 18:26:40 GMT</pubDate>
    <dc:creator>Peter_Cammaert</dc:creator>
    <dc:date>2017-08-22T18:26:40Z</dc:date>
    <item>
      <title>Use of variables</title>
      <link>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445726#M433264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&amp;nbsp; beginner here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My situation: one huge table (which takes my system about 5 minutes to calculate O.o)&lt;/P&gt;&lt;P&gt;Some of the columns which are calcualted have the same code in their calculation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Column 1:&amp;nbsp;&amp;nbsp; COUNT( DISTINCT x)) -5&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Column 2: COUNT (DISTINCT x)) * 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Column 3: COUNT (DISTINCT x)) * 10,5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Column 4: COUNT (DISTINCT x)) / 320&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Column 5: Count ( x )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(The calculations are not that simple, but I'm sure you get the gist)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question:&lt;/P&gt;&lt;P&gt;a) Is it worth it (&lt;STRONG&gt;Performance&lt;/STRONG&gt; wise!) to add a variable for same code parts =&amp;gt; "COUNT ( DISTINCT x))" ?&lt;/P&gt;&lt;P&gt;b) Can Qlikview cache only results of complete calculations, or also results of sub-calculations?&lt;/P&gt;&lt;P&gt;c) Can QlikView cache calculated variables?&lt;/P&gt;&lt;P&gt;d) how long does QlikView cache them? Until reload or only until restart of the application?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With a variable the columns would be calculated:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;// varX = COUNT(DISTINCT x))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Column 1: $(varX) -5&lt;/P&gt;&lt;P&gt;Column 2: &lt;SPAN style="font-size: 13.3333px;"&gt;$(varX) *2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Column 3: &lt;SPAN style="font-size: 13.3333px;"&gt;$(varX) * 10,5&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Column 4: &lt;SPAN style="font-size: 13.3333px;"&gt;$(varX) &amp;amp;320&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Column 5: Count ( x )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vic&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Aug 2017 13:59:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445726#M433264</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-22T13:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Use of variables</title>
      <link>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445727#M433265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/thread/161263"&gt;improving QlikView performance&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems that from &lt;A href="https://community.qlik.com/qlik-users/2310"&gt;troyansky&lt;/A&gt;‌ response that variable in fact help improve performance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Aug 2017 15:48:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445727#M433265</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-08-22T15:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Use of variables</title>
      <link>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445728#M433266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An alternative (local to a single object) approach could be to create a hidden column containing expression Count(Distinct x), naming it (use the label field for that) and referring to that expression label in all other visible expression columns except the last one. Let's say you called that column CntDistX, then the others would get the following expressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column 1 (hidden): &lt;SPAN style="font-family: 'courier new', courier;"&gt;Count(DISTINCT x) // Called 'CntDistX'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Column 2: &lt;SPAN style="font-family: 'courier new', courier;"&gt;CntDistX - 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;Column 3: &lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'courier new', courier;"&gt;CntDistX&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; * 2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;Column 4: &lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'courier new', courier;"&gt;CntDistX&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; * 10.5 // constants use US separators&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;Column 5: &lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'courier new', courier;"&gt;CntDistX&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; / 320&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Column 6: &lt;SPAN style="font-family: 'courier new', courier;"&gt;Count( x )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;This is easy to create and you will detect any performance improvements immediately.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Aug 2017 18:26:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445728#M433266</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2017-08-22T18:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Use of variables</title>
      <link>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445729#M433267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd say in this case using variables is unlikely to improve performance, because even with the variables, these expressions will be treated as separate formulas, so no caching can be used...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd second Peter's suggestion to add a hidden column that calculates the distinct count of x - that should indeed help in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Oleg Troyansky&lt;/P&gt;&lt;P&gt;Upgrade your Qlik skills at the &lt;A href="https://masterssummit.com/"&gt;Masters Summit for Qlik&lt;/A&gt; - coming to Boston, MA this October!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Aug 2017 19:56:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445729#M433267</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2017-08-22T19:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Use of variables</title>
      <link>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445730#M433268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much! This is great advice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 06:10:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-of-variables/m-p/1445730#M433268</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-23T06:10:36Z</dc:date>
    </item>
  </channel>
</rss>

