<?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: Setting a variable as todays date does not seem to store correct num value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329197#M496718</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;marcsliving, you're a genious - I never twigged that it was doing 18 divided by 11 divided by 2011. Good spot. I have followed your suggestion and am now doing the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=SUM({$&amp;lt;FactType={'Shop sales'}, Date={"&amp;lt;=$(=today()) &amp;gt;$(=AddMonths(today(), -12))"}&amp;gt;} Count)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And that works like a charm. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I'd still like to find a way to use a date variable in a set analysis expression.For example, if you wanted to include a date in a set analysis expression which was the result of a complicated or long calculation, and you had a lot of chart objects using the expression, you would want to do the calc in the script by setting a variable to keep things clean.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Nov 2011 20:20:06 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-11-18T20:20:06Z</dc:date>
    <item>
      <title>Setting a variable as todays date does not seem to store correct num value</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329194#M496713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a script, set a variable to today's date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Let vDateToday = today();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, create a text object on the sheet, and enter:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=vDateToday&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This displays '18/11/2011' in the text object. Great, that's what i would expect.(PS I'm in the UK, so I'm using dd/mm/yyyy).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if I change the text object to be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=$(vDateToday)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e. evaluate the expression. This displays 0.00081370643280141. Why?? The underlying numeric value for the date would be 40865. Where does 0.0008137... come from? This is giving me trouble as I am trying to use expressions in a set analysis statement and it isn't working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=SUM({$&amp;lt;FactType={'Shop sales'}, Date={"&amp;gt;=$(vDateToday) &amp;lt;$(vDateOneYearAgo)"}&amp;gt;} Count)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Nov 2011 17:03:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329194#M496713</guid>
      <dc:creator />
      <dc:date>2011-11-18T17:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a variable as todays date does not seem to store correct num value</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329195#M496714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For some reason using $() is evaluating it as 18 divided by 11 divided by 2011. Instead of using the variable in the set couldn't you just use today()?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new',courier;"&gt;=SUM({$&amp;lt;FactType={'Shop sales'}, Date=&lt;/SPAN&gt;{"&amp;gt;=$(=today())&lt;SPAN style="font-family: 'courier new',courier;"&gt; &amp;lt;$(vDateOneYearAgo)"}&amp;gt;} Count)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new',courier;"&gt;Edit:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new',courier;"&gt;you could also try removing the $ for the variable in the set analysis. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Nov 2011 17:11:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329195#M496714</guid>
      <dc:creator />
      <dc:date>2011-11-18T17:11:22Z</dc:date>
    </item>
    <item>
      <title>Setting a variable as todays date does not seem to store correct num value</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329196#M496715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The variable is probably being stored as text only.&amp;nbsp; It appears that in an input box, you can use the Number tab to define it as a date, and it will then have dual formats like any other date.&amp;nbsp; So that may be one answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, your set analysis SHOULD be working either way.&amp;nbsp; Given where you're inserting this text in the set analysis, QlikView has no reason to assume you're doing a calculation there.&amp;nbsp; It is a literal insertion of the text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I built this example to demonstrate that, and changing back and forth between text and date formats doesn't change the results.&amp;nbsp; Note that if you have a straight table with the set analysis as the first expression, the caption of the table will default to your set analysis before dollar sign expansion, and the column label will default to your set analysis AFTER dollar sign expansion.&amp;nbsp; This can be very helpful when debugging set analysis expressions.&amp;nbsp; In this case, we see that the date is correctly inserted into the set analysis, and again, whether or not it is just text or an actual date.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="DateVariableSetAnalysis.png" class="jive-image-thumbnail jive-image" onclick="" src="https://community.qlik.com/legacyfs/online/8750_DateVariableSetAnalysis.png" width="450" /&gt;&lt;/P&gt;&lt;P&gt;So I suggest doing something like I've done.&amp;nbsp; If you see a date in the label, your problem lies elsewhere.&amp;nbsp; Perhaps there are format differences?&amp;nbsp; The date formats must match for the set analysis to work since it's basically doing a text comparison instead of a date comparison.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All that said, I agree with marcsliving that just using today() should do the trick.&amp;nbsp; There seems no need to create a today variable when you have the today() function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Nov 2011 18:23:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329196#M496715</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-11-18T18:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a variable as todays date does not seem to store correct num value</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329197#M496718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;marcsliving, you're a genious - I never twigged that it was doing 18 divided by 11 divided by 2011. Good spot. I have followed your suggestion and am now doing the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=SUM({$&amp;lt;FactType={'Shop sales'}, Date={"&amp;lt;=$(=today()) &amp;gt;$(=AddMonths(today(), -12))"}&amp;gt;} Count)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And that works like a charm. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I'd still like to find a way to use a date variable in a set analysis expression.For example, if you wanted to include a date in a set analysis expression which was the result of a complicated or long calculation, and you had a lot of chart objects using the expression, you would want to do the calc in the script by setting a variable to keep things clean.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Nov 2011 20:20:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-variable-as-todays-date-does-not-seem-to-store-correct/m-p/329197#M496718</guid>
      <dc:creator />
      <dc:date>2011-11-18T20:20:06Z</dc:date>
    </item>
  </channel>
</rss>

