<?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: Count with a variable as condition in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219727#M866603</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, I define all the variable in the variable editor. As example on picture. Is it mandatory to use the script? &lt;BR /&gt;&lt;IMG alt="Capture.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/145931_Capture.JPG" style="height: 244px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Dec 2016 17:12:53 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-12-07T17:12:53Z</dc:date>
    <item>
      <title>Count with a variable as condition</title>
      <link>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219725#M866601</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;I'm struggeling to find a way to display a number of name per year according to a condition. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a number of line in my data file. Each Line is a personne,the year he have started and its result for the year&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example : If personne A have started in 2014 and a second person have started in 2015, I have&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Started_date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Result&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Personne A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2014&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;&amp;nbsp; 10000€&lt;/P&gt;&lt;P&gt;Personne A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2015&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;&amp;nbsp; 60000€&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Personne A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2016&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;&amp;nbsp; 60000€&lt;/P&gt;&lt;P&gt;Personne B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2015&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;&amp;nbsp; 8000€&lt;/P&gt;&lt;P&gt;Personne B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2016&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;&amp;nbsp; 48000€&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would like to display is the number of people, each year (bar chart) that have meet their target.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;In this case, compare to when they have started : first year : 10000€, second year : 30000€, Third year : 50000€&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example , I should have on my bar chart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2014 : 1&lt;/P&gt;&lt;P&gt;2015 : 1 (A have met his target of 30000 but B have not met his target of 10000)&lt;/P&gt;&lt;P&gt;2016 : 2 (A &lt;SPAN style="font-size: 13.3333px;"&gt;have met his target of 50000 and B have met his target of 30000)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My question is how can I do that? &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For now, I have done the following, using varaible: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Create a variable to calculate the age of the person &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vAge = 2016-year(Started_Date)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Then a second variable that check the target of the personn (according to his age): &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vTarget = if( $(vAge)&amp;gt;2,50000,if($(vAge)&amp;gt;1,30000,10000))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) Then a third variable that check if the result of the person is above his target: If yes --&amp;gt; 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vOk = if((Result)&amp;gt;$(vTarget),'1')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) To display the result, I'm using this function for the bar chart: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count(&lt;/P&gt;&lt;P&gt;{&amp;lt;Winner&amp;gt;={'1'}} Name&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For now, the only result I have is a bart chart that count the number of Name each year, no mather if they have met their target or not. But I think I have made a lot of mistake using the variable. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please help me? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219725#M866601</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Count with a variable as condition</title>
      <link>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219726#M866602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you doing this in the script to create a flag??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2016 16:05:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219726#M866602</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-12-07T16:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Count with a variable as condition</title>
      <link>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219727#M866603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, I define all the variable in the variable editor. As example on picture. Is it mandatory to use the script? &lt;BR /&gt;&lt;IMG alt="Capture.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/145931_Capture.JPG" style="height: 244px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2016 17:12:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219727#M866603</guid>
      <dc:creator />
      <dc:date>2016-12-07T17:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Count with a variable as condition</title>
      <link>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219728#M866604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;More detail : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I display the variable vOk inside a table, it does work. (I get 0 or 1 depending if the condition in the variable (&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;if((Result)&amp;gt;$(vTarget),'1')) &lt;/SPAN&gt; is right or not. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I try to count of many 1 or 0 I have, it doesn't work. ? Any Idea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 17:37:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-with-a-variable-as-condition/m-p/1219728#M866604</guid>
      <dc:creator />
      <dc:date>2016-12-08T17:37:09Z</dc:date>
    </item>
  </channel>
</rss>

