<?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 Using variables in Expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624354#M1100762</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a variable&lt;/P&gt;&lt;P&gt;vDevices=COUNT(DISTINCT {1} DEVICE_ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Top Chart&lt;/P&gt;&lt;P&gt;---------------&lt;/P&gt;&lt;P&gt;Suppose if I substitute the expression as below&lt;/P&gt;&lt;P&gt;=count(DISTINCT if(AVERAGE_JAM &amp;gt;=0, DEVICE_ID))/(COUNT(DISTINCT {1} DEVICE_ID))&lt;/P&gt;&lt;P&gt;I am not getting the correct chart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bottom Chart(OK)&lt;/P&gt;&lt;P&gt;-------------------------&lt;/P&gt;&lt;P&gt;While generating chart the expression contains as below&lt;/P&gt;&lt;P&gt;=count(DISTINCT if(AVERAGE_JAM &amp;gt;=0, DEVICE_ID))/$(vDevices)&lt;/P&gt;&lt;P&gt;This gives the correct result&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer to the chart&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="57006" alt="jam_dist.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/57006_jam_dist.JPG.jpg" style="width: 620px; height: 292px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What mistake I am making?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Apr 2014 15:12:21 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-04-10T15:12:21Z</dc:date>
    <item>
      <title>Using variables in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624354#M1100762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a variable&lt;/P&gt;&lt;P&gt;vDevices=COUNT(DISTINCT {1} DEVICE_ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Top Chart&lt;/P&gt;&lt;P&gt;---------------&lt;/P&gt;&lt;P&gt;Suppose if I substitute the expression as below&lt;/P&gt;&lt;P&gt;=count(DISTINCT if(AVERAGE_JAM &amp;gt;=0, DEVICE_ID))/(COUNT(DISTINCT {1} DEVICE_ID))&lt;/P&gt;&lt;P&gt;I am not getting the correct chart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bottom Chart(OK)&lt;/P&gt;&lt;P&gt;-------------------------&lt;/P&gt;&lt;P&gt;While generating chart the expression contains as below&lt;/P&gt;&lt;P&gt;=count(DISTINCT if(AVERAGE_JAM &amp;gt;=0, DEVICE_ID))/$(vDevices)&lt;/P&gt;&lt;P&gt;This gives the correct result&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer to the chart&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="57006" alt="jam_dist.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/57006_jam_dist.JPG.jpg" style="width: 620px; height: 292px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What mistake I am making?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 15:12:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624354#M1100762</guid>
      <dc:creator />
      <dc:date>2014-04-10T15:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624355#M1100763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to add total to your count expression like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=count(DISTINCT if(AVERAGE_JAM &amp;gt;=0, DEVICE_ID))/(COUNT(DISTINCT &lt;STRONG&gt;TOTAL&lt;/STRONG&gt; {1} DEVICE_ID))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 15:28:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624355#M1100763</guid>
      <dc:creator>jerem1234</dc:creator>
      <dc:date>2014-04-10T15:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624356#M1100764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jerem. Appreciate. But while using variable it is working without TOTAL. Do you know why?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 15:30:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624356#M1100764</guid>
      <dc:creator />
      <dc:date>2014-04-10T15:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624357#M1100765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is because of the dimension on the chart. The {1} ignores selections, but does not ignore the dimensions in the chart. Therefore, you need to use total to ignore that dimension to get the total amount of devices. It works in the variable, because it is calculating it BEFORE you use it in chart, and therefore does not have an dimensions aggregating it. You can see for yourself by going into your variable and deleting the "=" sign. The chart you have for the variable will now be wrong. Without the "=" sign, the expression in the variable is calculated in the chart and not before.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 15:36:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624357#M1100765</guid>
      <dc:creator>jerem1234</dc:creator>
      <dc:date>2014-04-10T15:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624358#M1100766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;It has to do with dimensionality. If you use the expression without a variable --&amp;gt; &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;=count(DISTINCT if(AVERAGE_JAM &amp;gt;=0, DEVICE_ID))/(COUNT(DISTINCT {1} DEVICE_ID)), &lt;/STRONG&gt;the expression will be calculated once for all the dimension&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other hand, if you store =&lt;STRONG style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;COUNT(DISTINCT {1} DEVICE_ID) &lt;/STRONG&gt;in a variable, this part of the expression will be calculated for every dimension value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also try something like this: &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;count(DISTINCT if(AVERAGE_JAM &amp;gt;=0, DEVICE_ID))/&lt;STRONG&gt;$(=COUNT(DISTINCT &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;TOTAL&lt;/STRONG&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt; {1} DEVICE_ID)) &lt;/STRONG&gt;that would be like using a local variable,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 15:40:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624358#M1100766</guid>
      <dc:creator>jaimeaguilar</dc:creator>
      <dc:date>2014-04-10T15:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624359#M1100767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;vDevices=COUNT(DISTINCT {1} DEVICE_ID)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;your variable gives you the overall total &lt;STRONG&gt;ignoring all dimension&lt;/STRONG&gt; but &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;count(DISTINCT if(AVERAGE_JAM &amp;gt;=0, DEVICE_ID))/(COUNT(DISTINCT {1} DEVICE_ID))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when you use same expression in your chart &lt;STRONG&gt;it is evaluated with respect to each dimension&lt;/STRONG&gt; that why you are getting 100% &lt;/P&gt;&lt;P&gt;and that's why you have to use&lt;STRONG&gt; TOTAL&lt;/STRONG&gt; in your expression as suggested by &lt;A href="https://community.qlik.com/qlik-users/114213"&gt;jerem1234&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 16:01:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-in-Expression/m-p/624359#M1100767</guid>
      <dc:creator>PrashantSangle</dc:creator>
      <dc:date>2014-04-10T16:01:41Z</dc:date>
    </item>
  </channel>
</rss>

