<?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: Set analysis: compare two date fields in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509697#M599201</link>
    <description>&lt;P&gt;Are CREATED_DATE and DATE coming from the same table in your data model? Have you tried this with If statement?&lt;/P&gt;&lt;PRE&gt;Avg(If(CREATED_DATE &amp;gt;= DATE, CREATED_DATE - DATE))&lt;/PRE&gt;&lt;P&gt;You can also try this&lt;/P&gt;&lt;PRE&gt;Avg(RangeMax(CREATED_DATE - DATE, 0))&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Nov 2018 12:48:37 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-11-20T12:48:37Z</dc:date>
    <item>
      <title>Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509692#M599200</link>
      <description>&lt;P&gt;Hi everybody,&lt;BR /&gt;&lt;BR /&gt;I am struggling creating a set analysis using two date fields.&lt;/P&gt;&lt;P&gt;What I want to do is to calculate the difference (days) between two fields but only for those cases where the one value is greater than the other.&lt;/P&gt;&lt;P&gt;avg({$&amp;lt;CREATED_DATE= {"=CREATED_DATE &amp;gt;= DATE"}&amp;gt;} CREATED_DATE - DATE)&lt;BR /&gt;&lt;BR /&gt;In my case, for all cases&amp;nbsp;were the created date is later than the date, I want to calculate the difference.&lt;BR /&gt;&lt;BR /&gt;But it is not possible to get this working.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Florian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 12:41:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509692#M599200</guid>
      <dc:creator>florian_kloster</dc:creator>
      <dc:date>2018-11-20T12:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509697#M599201</link>
      <description>&lt;P&gt;Are CREATED_DATE and DATE coming from the same table in your data model? Have you tried this with If statement?&lt;/P&gt;&lt;PRE&gt;Avg(If(CREATED_DATE &amp;gt;= DATE, CREATED_DATE - DATE))&lt;/PRE&gt;&lt;P&gt;You can also try this&lt;/P&gt;&lt;PRE&gt;Avg(RangeMax(CREATED_DATE - DATE, 0))&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 12:48:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509697#M599201</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-11-20T12:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509703#M599202</link>
      <description>&lt;P&gt;Hi &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;yes, both fields are in the same table. I could use the if condition as well, but&amp;nbsp;is it possible to realize it using set analysis?&lt;BR /&gt;Someone told me that this would save resources.&lt;/P&gt;&lt;P&gt;Thanks for your&amp;nbsp;thoughts,&lt;BR /&gt;Florian&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 12:56:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509703#M599202</guid>
      <dc:creator>florian_kloster</dc:creator>
      <dc:date>2018-11-20T12:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509710#M599203</link>
      <description>&lt;P&gt;If you want to use set analysis... I would suggest you to create a flag in the script (since they are coming from the same table in the script)&lt;/P&gt;&lt;PRE&gt;If(CREATED_DATE &amp;gt;= DATE, 1, 0) as Flag,&lt;BR /&gt;CREATED_DATE - DATE as DATE_DIFF&lt;/PRE&gt;&lt;P&gt;and then use this&lt;/P&gt;&lt;PRE&gt;Avg({&amp;lt;Flag = {'1'}&amp;gt;} DATE_DIFF))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 13:02:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509710#M599203</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-11-20T13:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509715#M599204</link>
      <description>&lt;P&gt;Hi, yes this is a feasible solution. It&amp;nbsp;was mentioned in other posts in the past.&lt;/P&gt;&lt;P&gt;But I would&amp;nbsp;like to avoid creating unnecessary fields in my database - especially as I would like to create such a funnel view for more&amp;nbsp;steps&amp;nbsp;(8 steps in the funnel).&lt;/P&gt;&lt;P&gt;So&amp;nbsp;am I right assuming that there is NO way to realizes this&amp;nbsp;using set analysis without creating a flag field in the script?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Florian&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 13:06:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509715#M599204</guid>
      <dc:creator>florian_kloster</dc:creator>
      <dc:date>2018-11-20T13:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509734#M599205</link>
      <description>&lt;P&gt;1) You are looking to optimize yet you are hesitant of creating a flag field which will only take 1 or 0 value? Not sure I understand this.... if you&amp;nbsp;go through&amp;nbsp;the below thread, you will see that a flag field which store 1 or 0 should not have a huge impact on your data model.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/Symbol-Tables-and-Bit-Stuffed-Pointers/ba-p/1475369" target="_blank"&gt;Symbol Tables and Bit Stuffed Pointers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2) You can still do this without creating a field... but against which field are you actually testing this. For example, you might need a project where this true. So, in that case you can do this&lt;/P&gt;&lt;PRE&gt;Avg({$&amp;lt;Project_ID = {"=CREATED_DATE &amp;gt;= DATE"}&amp;gt;} CREATED_DATE - DATE)&lt;/PRE&gt;&lt;P&gt;But this is saying that a ProjectID will have a single CREATED_DATE and a single DATE.... if it has multiple of either of the fields... it won't work.&amp;nbsp;So, the above set analysis will pick those projects where CREATED_DATE &amp;gt;= DATE. What is your field against which you can run this condition?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 13:29:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509734#M599205</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-11-20T13:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509740#M599206</link>
      <description>&lt;P&gt;Hey &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;first of all thank you very much! This is exactly what I am looking for. I can use the ID as this is an unique identifier. This results in what should be correct.&lt;/P&gt;&lt;P&gt;But concerning your thoughts about performance and flagging:&lt;BR /&gt;True, flagging does not increase the data amount, but I don't see the elegance in creating a flag for one single analysis if it is possible to do it without this work through.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much and have a great day! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Florian&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 13:38:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509740#M599206</guid>
      <dc:creator>florian_kloster</dc:creator>
      <dc:date>2018-11-20T13:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509845#M599207</link>
      <description>&lt;P&gt;Did you try the second suggestion from Sunny with the rangemax() ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 15:07:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509845#M599207</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-11-20T15:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis: compare two date fields</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509853#M599208</link>
      <description>&lt;P&gt;Your flags need only to be 0 or 1 if you want to multiply anything with it. Otherwise by using them within a set analysis your flag could contain 1 for one metric and 2 for another and so on - depending on your data and requirements it might be possible to nest multiple and even overlapping flags into a single one. If it's worth to increase here the complexity against more simpler but redundant approaches ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 15:15:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-compare-two-date-fields/m-p/1509853#M599208</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-11-20T15:15:25Z</dc:date>
    </item>
  </channel>
</rss>

