<?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 Set or Let? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264055#M579820</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;SET is, exactly as you say, a literal declaration rather than an evaluation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET v1 = 1+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt;&amp;nbsp; v1 will have the value 1+1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET v1 = 1+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt;&amp;nbsp; v1 will have the value 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will almost exclusively use LET with variables.&amp;nbsp; Unless I need to create a macro function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://qliktips.blogspot.com/2011/03/parameters-in-dollar-expansion.html"&gt;http://qliktips.blogspot.com/2011/03/parameters-in-dollar-expansion.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For dates, I always use Floor because it means that I don't need to worry about the single quotes when using it and I don't need to try and re-convert it again.&amp;nbsp; E.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Where DateField &amp;gt; $(vDateStart)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Feb 2012 14:08:39 GMT</pubDate>
    <dc:creator>stephencredmond</dc:creator>
    <dc:date>2012-02-09T14:08:39Z</dc:date>
    <item>
      <title>Set or Let?</title>
      <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264048#M579813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, i'm desesperated with this variables!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET DateFormat='D/M/YYYY';&lt;/P&gt;&lt;P&gt;SET TimestampFormat='D/M/YYYY hh:mm:ss[.fff]';&lt;/P&gt;&lt;P&gt;SET MonthNames='jan;fev;mar;abr;mai;jun;jul;ago;set;out;nov;dez';&lt;/P&gt;&lt;P&gt;SET DayNames='seg;ter;qua;qui;sex;sáb;dom';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if i use LET for a variable :&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;LET vExercicioRef=MakeDate(2011,2,1) ; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the expression date($(vExercicioRef)) returns 12/31/1899&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and when use SET&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;LET vExercicioRef=MakeDate(2011,2,1) ; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the result is right: it returns 2/28/2011&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2012 14:49:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264048#M579813</guid>
      <dc:creator>bimartingo</dc:creator>
      <dc:date>2012-02-08T14:49:52Z</dc:date>
    </item>
    <item>
      <title>Set or Let?</title>
      <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264049#M579814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; when you use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set before a variable it would put the text into the variable&lt;/P&gt;&lt;P&gt;so in your case the variable would be &lt;/P&gt;&lt;P&gt; vExercicioRef=MakeDate(2011,2,1) ; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you put let before the variable it would calculate the formula and put the value to tha varaible&lt;/P&gt;&lt;P&gt;so in your case &lt;/P&gt;&lt;P&gt;let&amp;nbsp; vExercicioRef=MakeDate(2011,2,1) ;&lt;/P&gt;&lt;P&gt;the result will be&lt;/P&gt;&lt;P&gt;vExercicioRef = 01/02/2012&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2012 19:52:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264049#M579814</guid>
      <dc:creator>lironbaram</dc:creator>
      <dc:date>2012-02-08T19:52:11Z</dc:date>
    </item>
    <item>
      <title>Set or Let?</title>
      <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264050#M579815</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;Use this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #636363; font-family: Arial; font-size: 12px; background-color: #eef4f9;"&gt;LET vExercicioRef=Floor(MakeDate(2011,2,1)) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then the value in the variable will be the integer date serial and this tends, in my experience, to be much easier to use in a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2012 20:41:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264050#M579815</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2012-02-08T20:41:33Z</dc:date>
    </item>
    <item>
      <title>Set or Let?</title>
      <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264051#M579816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stephen, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;very useful information, my previous experience had teach me that floor or int are very useful for removing the time part of datetime values. It's like an universal solution , independent of technology. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, it seems to me that the answer for my question is: when we use calculated expressions, LET is better. SET works more like a constant/literal expression declaration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So is my understanding. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 13:02:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264051#M579816</guid>
      <dc:creator>bimartingo</dc:creator>
      <dc:date>2012-02-09T13:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Set or Let?</title>
      <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264052#M579817</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;What is happening in your expression not using Floor() -and sounds kind of buggy to me-, is that LET evaluates first the right part, then stores, so the logic steps that QlikView does according to your example are&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;LET vExercicioRef = MakeDate(2011, 2 ,1); // your sentence&lt;/P&gt;&lt;P&gt;// QlikView does&lt;/P&gt;&lt;P&gt;MakeDate(2011, 2, 1) = 01/02/2011&lt;/P&gt;&lt;P&gt;01 / 02 / 2011 = 0,000248632&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// So&lt;/P&gt;&lt;P&gt;Date($(vExercicioRef)) = Date(0.000248632) = 30/12/1899&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And that is because you are evaluating twice. The first when using LET (creates the date), the second when using $() (dividing the day into the value of month into the value of year). If you use instead&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Date(vExercicioRef)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result will be as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that sheds some light.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 13:19:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264052#M579817</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2012-02-09T13:19:06Z</dc:date>
    </item>
    <item>
      <title>Set or Let?</title>
      <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264053#M579818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Migel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid this behavior, I often use single quotation marks.&amp;nbsp; Notice the differnece:&lt;BR /&gt;date(02/09/2012) returns 12/30/1899&lt;BR /&gt;date('02/09/2012') returns 02/09/2012&lt;BR /&gt;So, the safe way to use variable cretated by LET is this:&lt;BR /&gt;Date('$(vExercicioRef)')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 13:38:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264053#M579818</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-02-09T13:38:52Z</dc:date>
    </item>
    <item>
      <title>Set or Let?</title>
      <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264054#M579819</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;&lt;/P&gt;&lt;P&gt;Thanks for sharing. I was only showing how QlikView deals with dates. I always use the no-quotes no-dollar-expansion when the variable has been assigned with LET, and I don't need to evaluate twice the results. It makes more sense to me and makes the code cleaner. By the way, I always try to use Date#(something, 'format') instead of MakeDate() whenever possible, but that's another story&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 13:52:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264054#M579819</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2012-02-09T13:52:11Z</dc:date>
    </item>
    <item>
      <title>Set or Let?</title>
      <link>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264055#M579820</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;SET is, exactly as you say, a literal declaration rather than an evaluation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET v1 = 1+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt;&amp;nbsp; v1 will have the value 1+1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET v1 = 1+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt;&amp;nbsp; v1 will have the value 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will almost exclusively use LET with variables.&amp;nbsp; Unless I need to create a macro function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://qliktips.blogspot.com/2011/03/parameters-in-dollar-expansion.html"&gt;http://qliktips.blogspot.com/2011/03/parameters-in-dollar-expansion.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For dates, I always use Floor because it means that I don't need to worry about the single quotes when using it and I don't need to try and re-convert it again.&amp;nbsp; E.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Where DateField &amp;gt; $(vDateStart)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 14:08:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-or-Let/m-p/264055#M579820</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2012-02-09T14:08:39Z</dc:date>
    </item>
  </channel>
</rss>

