<?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 If Statement in a Macro in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/If-Statement-in-a-Macro/m-p/145577#M24269</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a field call Shift time which is Day or Night. Based on the current time that the Application is opened I want to display only the Day shift hours production or the Night shift production.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My If statement would look like this&lt;/P&gt;&lt;P&gt;If (Hour(localtime()) between 7 and 19 then 'Day','Night')&lt;/P&gt;&lt;P&gt;I have no idea how to do this or where to start.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jun 2009 09:07:07 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-06-02T09:07:07Z</dc:date>
    <item>
      <title>If Statement in a Macro</title>
      <link>https://community.qlik.com/t5/QlikView/If-Statement-in-a-Macro/m-p/145577#M24269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a field call Shift time which is Day or Night. Based on the current time that the Application is opened I want to display only the Day shift hours production or the Night shift production.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My If statement would look like this&lt;/P&gt;&lt;P&gt;If (Hour(localtime()) between 7 and 19 then 'Day','Night')&lt;/P&gt;&lt;P&gt;I have no idea how to do this or where to start.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2009 09:07:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Statement-in-a-Macro/m-p/145577#M24269</guid>
      <dc:creator />
      <dc:date>2009-06-02T09:07:07Z</dc:date>
    </item>
    <item>
      <title>If Statement in a Macro</title>
      <link>https://community.qlik.com/t5/QlikView/If-Statement-in-a-Macro/m-p/145578#M24270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Susan&lt;/P&gt;&lt;P&gt;The following should help you out.&lt;/P&gt;&lt;P&gt;1. Create a variable in the application called vTimeOpen&lt;/P&gt;&lt;P&gt;2. Create a Macro in your Macro code as follows:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;SUB SetOpenTime&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;ActiveDocument.Variables("vTimeOpen").SetContent HOUR(Now()), true&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;END SUB&lt;/P&gt;&lt;P&gt;3. Call this Macro when opening the document, go to Settings, Document Properties, Macros, then on the document event triggers section, add the macro to the OnOpen event. This means that every time the document is opened, this macro will be called and the value of the variable will be set to the current hour.&lt;/P&gt;&lt;P&gt;4. In you chart/table etc, you can use the following expression: =IF ( vTimeOpen &amp;gt;= 7 AND vTimeOpen &amp;lt;=19 , 'Day', 'Night' )&lt;/P&gt;&lt;P&gt;That should do it for you.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nigel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2009 14:53:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Statement-in-a-Macro/m-p/145578#M24270</guid>
      <dc:creator />
      <dc:date>2009-06-02T14:53:39Z</dc:date>
    </item>
  </channel>
</rss>

