<?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 Removing Years from Listbox in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339470#M125267</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 am new to qlikview and I am trying to create a list box that only shows certain years.&amp;nbsp; &lt;/P&gt;&lt;P&gt;In the database where I get my information from (using SQL), I have a field called &lt;STRONG&gt;'Logdate'.&amp;nbsp; &lt;/STRONG&gt;In my load script I have entered the following to create two new fields called &lt;STRONG&gt;Logdate_year &lt;/STRONG&gt;and &lt;STRONG&gt;Logdate_month &lt;/STRONG&gt;(which is an exact copy and still show the date as &lt;STRONG&gt;2012-03-01 00:00:00&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then created two list boxes, one which has just the year in and the other which has just the month in.&amp;nbsp; In those list boxes I created the following expressions in the properties -&amp;gt; Field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ListBox 1&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =YEAR(logdate_year)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ListBox 2&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =MONTH(logdate_month)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However on my &lt;STRONG&gt;ListBox1 &lt;/STRONG&gt;which now just displays the year, I want to only show the last &lt;STRONG&gt;4&lt;/STRONG&gt; years.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Currently the following years show in my list box &lt;STRONG&gt;2012,2011,2010,2009,2008,2007,2006 &lt;/STRONG&gt;and &lt;STRONG&gt;2005 &lt;/STRONG&gt;(The oldest date in my Database is 2005-01-01 00:00:00)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to be able to show just the following dates, &lt;STRONG&gt;2012,2011,2010 and 2009&lt;/STRONG&gt;.&amp;nbsp; In addition I want this to change every year, so therefore when we start adding &lt;STRONG&gt;2013 &lt;/STRONG&gt;to the database, I want it to show &lt;STRONG&gt;2013,2012,2011,2010&lt;/STRONG&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Aug 2012 10:04:07 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-08-06T10:04:07Z</dc:date>
    <item>
      <title>Removing Years from Listbox</title>
      <link>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339470#M125267</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 am new to qlikview and I am trying to create a list box that only shows certain years.&amp;nbsp; &lt;/P&gt;&lt;P&gt;In the database where I get my information from (using SQL), I have a field called &lt;STRONG&gt;'Logdate'.&amp;nbsp; &lt;/STRONG&gt;In my load script I have entered the following to create two new fields called &lt;STRONG&gt;Logdate_year &lt;/STRONG&gt;and &lt;STRONG&gt;Logdate_month &lt;/STRONG&gt;(which is an exact copy and still show the date as &lt;STRONG&gt;2012-03-01 00:00:00&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then created two list boxes, one which has just the year in and the other which has just the month in.&amp;nbsp; In those list boxes I created the following expressions in the properties -&amp;gt; Field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ListBox 1&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =YEAR(logdate_year)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ListBox 2&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =MONTH(logdate_month)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However on my &lt;STRONG&gt;ListBox1 &lt;/STRONG&gt;which now just displays the year, I want to only show the last &lt;STRONG&gt;4&lt;/STRONG&gt; years.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Currently the following years show in my list box &lt;STRONG&gt;2012,2011,2010,2009,2008,2007,2006 &lt;/STRONG&gt;and &lt;STRONG&gt;2005 &lt;/STRONG&gt;(The oldest date in my Database is 2005-01-01 00:00:00)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to be able to show just the following dates, &lt;STRONG&gt;2012,2011,2010 and 2009&lt;/STRONG&gt;.&amp;nbsp; In addition I want this to change every year, so therefore when we start adding &lt;STRONG&gt;2013 &lt;/STRONG&gt;to the database, I want it to show &lt;STRONG&gt;2013,2012,2011,2010&lt;/STRONG&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2012 10:04:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339470#M125267</guid>
      <dc:creator />
      <dc:date>2012-08-06T10:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Years from Listbox</title>
      <link>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339471#M125268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest to create the year and month fields in the load script, but in your list box, it could probably look like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=if( Year(logdate_year) &amp;gt; year(today())-4, year(logdate_year) )&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;edit:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Or if you want to check against the max date in your database instead today():&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=if( Year(logdate_year) &amp;gt; max(total year(logdate_year))-4, year(logdate_year) )&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2012 10:13:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339471#M125268</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-08-06T10:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Years from Listbox</title>
      <link>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339472#M125269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;=if(Year&amp;gt; Year(Today())-4,Year)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try This Hope this Helps!!! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2012 10:24:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339472#M125269</guid>
      <dc:creator>rajni_batra</dc:creator>
      <dc:date>2012-08-06T10:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Years from Listbox</title>
      <link>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339473#M125270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Swuehl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I took your advice and sorted the data in the load script.&amp;nbsp; I changed the date to a number, removed the amount of days I wanted to removed as a number and then converted back into a date.&amp;nbsp; It has worked brilliantly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2012 11:42:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339473#M125270</guid>
      <dc:creator />
      <dc:date>2012-08-06T11:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Years from Listbox</title>
      <link>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339474#M125271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I have understood the issue and the solution, take care that when you will select a Year in your listbox, you won't select the Year but the the values of &lt;STRONG&gt;Logdate_year&lt;/STRONG&gt; that matches with the result of the expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It means that when you think selecting 1 value in Year, in fact you will select 365 dates. You can have issues in advanced scripting, and other tricky issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest to:&lt;/P&gt;&lt;P&gt;- calculate a field Year in script&lt;/P&gt;&lt;P&gt;- calculate a field Month in script&lt;/P&gt;&lt;P&gt;- If you want only the 4 last years, reduce your data to keep only the 4 last years&lt;/P&gt;&lt;P&gt;- If you want to keep all your data but display only the 4 last years in listbox, you can link fact table to Year table only for the 4 last years, or link the fact table to the Year table for all rows and set to null values that are less than the 4 last years :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FACT_TABLE&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;id_year&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;YEAR_TABLE&lt;/P&gt;&lt;P&gt;id_year&lt;/P&gt;&lt;P&gt;value_year : set to null if &amp;lt; Year(Today()) - 3&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2012 12:43:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Removing-Years-from-Listbox/m-p/339474#M125271</guid>
      <dc:creator>nstefaniuk</dc:creator>
      <dc:date>2012-08-06T12:43:56Z</dc:date>
    </item>
  </channel>
</rss>

