<?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 How to select relative dates? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177818#M45257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael, thanks for the suggestion. I have tried and it is not working. Below is my code, I have tried the Date() function with and without the format string. Any suggestions? When I change the integer value in the input box associated with the vRelativeDates variable no selection is made in the RollupDate field.&lt;/P&gt;&lt;P&gt;Thanks, Jim&lt;/P&gt;&lt;P&gt;&lt;A href="http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/4024.qv04.png"&gt;&lt;IMG alt="" border="0" src="http://community.qlik.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Discussions.Components.Files/11/4024.qv04.png" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Mar 2011 16:58:03 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-03-24T16:58:03Z</dc:date>
    <item>
      <title>How to select relative dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177814#M45253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to be able to select relative dates. For example: "Past 7 Days", "Past 30 Days", etc. Would like to have a drop down list such that when the user selected "Past 7 days" a selection is done on the date field as displayed in the screen shot below. How do I select the previous 7 days when the user selects "Last 7 Days" from the drop down. Or is there a better way to do this. Thanks.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="error loading image" class="jive-image error-loading-image" src="https://community.qlik.com/legacyfs/online/-3920_sourceID:3920" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2011 22:05:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177814#M45253</guid>
      <dc:creator />
      <dc:date>2011-03-23T22:05:34Z</dc:date>
    </item>
    <item>
      <title>How to select relative dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177815#M45254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Create a variable vRelativeDays (you have it). Allow to enter only positive integer.&lt;BR /&gt;2. Create input box with this variable. Use label like "Last N Days".&lt;BR /&gt;3. In the document properties, tab Triggers, attach the next trigger to the vRelativeDays variable, on input:&lt;BR /&gt; Select in field: Date&lt;BR /&gt; Search string: &lt;STRONG&gt;='&amp;lt;=' &amp;amp; date(today()) &amp;amp; '&amp;gt;=' &amp;amp; date(today() - vRelativeDays)&lt;/STRONG&gt;&lt;BR /&gt;As soon as you enter a number in the input box, the Date range will be selected.&lt;/P&gt;&lt;P&gt;Certainly you can restrict variable values to a list, for example allow only 7, 30, ... I prefer to have maximum flexibility.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 02:19:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177815#M45254</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-03-24T02:19:32Z</dc:date>
    </item>
    <item>
      <title>How to select relative dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177816#M45255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jims,&lt;/P&gt;&lt;P&gt;A quick solution (but looking for better one as well) would be to build a dedicated table to pre-defined your selection.&lt;/P&gt;&lt;P&gt;And replace your inputbox by a simple listbox (containing the field 'Selection') or a MultiBox.&lt;/P&gt;&lt;P&gt;Script would be:&lt;/P&gt;&lt;P&gt;MaxDate:&lt;BR /&gt;Load Max(Date) As MaxDate&lt;BR /&gt;Resident Facts;&lt;BR /&gt;&lt;BR /&gt;Let v_Max=peek('MaxDate');&lt;BR /&gt;Drop Table MaxDate;&lt;BR /&gt;&lt;BR /&gt;As of:&lt;BR /&gt;LOAD&lt;BR /&gt; Date($(v_Max) - iterno() + 1) as Date,&lt;BR /&gt;'Last 7 days' as Selection&lt;BR /&gt;AutoGenerate(1)&lt;BR /&gt;while iterNo() &amp;lt; 7&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;And then with a concatenate statement, you continue to build your pre-defined selection.&lt;/P&gt;&lt;P&gt;I was trying to execute the following script (simpler), but I can't make it work (I guess it is because of the Max() function; which prevent the iterno() counter to iterate). If someone can confirm or correct me.&lt;/P&gt;&lt;P&gt;As of:&lt;BR /&gt;LOAD&lt;BR /&gt; Date(Max(Date)) - iterno() + 1) as Date,&lt;BR /&gt;'Last 7 days' as Selection&lt;BR /&gt;Resident Facts&lt;BR /&gt;while iterNo() &amp;lt; 7&lt;BR /&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 03:10:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177816#M45255</guid>
      <dc:creator />
      <dc:date>2011-03-24T03:10:31Z</dc:date>
    </item>
    <item>
      <title>How to select relative dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177817#M45256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;Excellent, I did not know you could put a trigger on a input box!&lt;/P&gt;&lt;P&gt;Could you help to understand why the following code does only produce 1 single observation.&lt;/P&gt;&lt;P&gt;As of:&lt;BR /&gt;LOAD&lt;BR /&gt; Date(Max(Date)) - iterno() + 1) as Date,&lt;BR /&gt;'Last 7 days' as Selection&lt;BR /&gt;Resident Facts&lt;BR /&gt;while iterNo() &amp;lt; 7&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;It is because I am using the Max() function, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 03:23:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177817#M45256</guid>
      <dc:creator />
      <dc:date>2011-03-24T03:23:39Z</dc:date>
    </item>
    <item>
      <title>How to select relative dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177818#M45257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael, thanks for the suggestion. I have tried and it is not working. Below is my code, I have tried the Date() function with and without the format string. Any suggestions? When I change the integer value in the input box associated with the vRelativeDates variable no selection is made in the RollupDate field.&lt;/P&gt;&lt;P&gt;Thanks, Jim&lt;/P&gt;&lt;P&gt;&lt;A href="http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/4024.qv04.png"&gt;&lt;IMG alt="" border="0" src="http://community.qlik.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Discussions.Components.Files/11/4024.qv04.png" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 16:58:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177818#M45257</guid>
      <dc:creator />
      <dc:date>2011-03-24T16:58:03Z</dc:date>
    </item>
    <item>
      <title>How to select relative dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177819#M45258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jim,&lt;BR /&gt;The expression looks fine. Except, I don't like the '&lt;STRONG&gt;=&lt;/STRONG&gt;' before the field name - try to remove it.&lt;BR /&gt;If it doesn't help, quesions:&lt;BR /&gt; - Is RollupDate the correct field name? I see Date in your first post. I understand it could be just a lable - just to make sure.&lt;BR /&gt; - Is format of the RollupDate exactly 'MM/DD/YY'? If it is not the right one, it can't work.&lt;BR /&gt; - Did you assign this action to the variable vRelativeDates?&lt;BR /&gt;You can test the action itself by assigning it to a button or text box.&lt;BR /&gt;(I have tested the solution before posting it - it works)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 17:36:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-relative-dates/m-p/177819#M45258</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-03-24T17:36:05Z</dc:date>
    </item>
  </channel>
</rss>

