<?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 Help with a If calculation in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333088#M1177782</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks to both of you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Mar 2012 12:26:55 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-03-02T12:26:55Z</dc:date>
    <item>
      <title>Help with a If calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333085#M1177779</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 have two datefields and want the diffrens in between them. I do this by Stopdate - StartDate.&lt;/P&gt;&lt;P&gt;But in some fields the StopDate are wrong. So I only want the calculation for the fields were Stopdate are larger then Startdate. I do the caluclation in the script as&amp;nbsp; Date(Date#(StopDate, 'YYYYMMDD'), 'YYYY-MM-DD') - Date(Date#(StartDate, 'YYYYMMDD'), 'YYYY-MM-DD') as DayDiff&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess I should use a IF statemeant, can anyone help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 12:05:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333085#M1177779</guid>
      <dc:creator />
      <dc:date>2012-03-02T12:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a If calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333086#M1177780</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;If I understand correctly, you only need to add a conditional so the expression is only calculated when StopDate is greater than StartDate, so the following should do it:&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;If(StopDate &amp;gt; StartDate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Date#(StopDate, 'YYYYMMDD'), 'YYYY-MM-DD') - Date(Date#(StartDate, 'YYYYMMDD'), 'YYYY-MM-DD') &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 0) as DayDiff // 0 is the default value when StopDate is not greater than StartDate: change it according to your needs&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 12:09:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333086#M1177780</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2012-03-02T12:09:01Z</dc:date>
    </item>
    <item>
      <title>Help with a If calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333087#M1177781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Try with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(Date(Date#(StopDate, 'YYYYMMDD'), 'YYYY-MM-DD')&amp;gt;Date(Date#(StartDate, 'YYYYMMDD'), 'YYYY-MM-DD'),Interval(Date(Date#(StopDate, 'YYYYMMDD'), 'YYYY-MM-DD')-Date(Date#(StartDate, 'YYYYMMDD'), 'YYYY-MM-DD'),'D')) as DayDiff&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;Celambarasan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 12:09:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333087#M1177781</guid>
      <dc:creator>CELAMBARASAN</dc:creator>
      <dc:date>2012-03-02T12:09:15Z</dc:date>
    </item>
    <item>
      <title>Help with a If calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333088#M1177782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks to both of you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 12:26:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-a-If-calculation/m-p/333088#M1177782</guid>
      <dc:creator />
      <dc:date>2012-03-02T12:26:55Z</dc:date>
    </item>
  </channel>
</rss>

