<?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 Question - DateField1 &amp;gt;= DateField2 in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Set-Analysis-Question-DateField1-gt-DateField2/m-p/2158754#M93927</link>
    <description>&lt;P&gt;Thank you for the detailed response, this really helped me better understand how this was working. All of the proposed solutions worked!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2024 21:23:04 GMT</pubDate>
    <dc:creator>Brysonds</dc:creator>
    <dc:date>2024-01-05T21:23:04Z</dc:date>
    <item>
      <title>Set Analysis Question - DateField1 &gt;= DateField2</title>
      <link>https://community.qlik.com/t5/App-Development/Set-Analysis-Question-DateField1-gt-DateField2/m-p/2158709#M93918</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have a pretty simple request to only show sales when DateField1 &amp;gt;= Datefield2. I tried a few different iterations of set analysis and either get the same amount as sum(sales) or get 0. Both date fields are in the same YYYY-MM-DD format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example 1:&lt;/P&gt;
&lt;P&gt;Sum(&lt;SPAN&gt;{&amp;lt;DateField1 = {&lt;/SPAN&gt;&lt;SPAN class="hljs-string"&gt;"&lt;SPAN class="hljs-subst"&gt;$(= '&amp;gt;=' &amp;amp; DateField2)&lt;/SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;}&amp;gt;} Sales) results in the same as Sum(Sales)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example 2:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sum({&amp;lt;DateField1 = {&lt;SPAN class="hljs-string"&gt;"&amp;gt;=&lt;SPAN class="hljs-subst"&gt;$(=DateField2)&lt;/SPAN&gt;"&lt;/SPAN&gt;}&amp;gt;} Sales) results in 0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example 3:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sum({&amp;lt;DateField1 = {&lt;SPAN class="hljs-string"&gt;"&amp;gt;=&lt;SPAN class="hljs-subst"&gt;$(=Date(DateField2)&lt;/SPAN&gt;)"&lt;/SPAN&gt;}&amp;gt;} Sales) results in 0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any alternatives or ideas on how to get this working?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I manually type in a date like this, it works fine:&lt;/P&gt;
&lt;P&gt;Sum({&amp;lt;DateField1 = {"&amp;gt;=$(=Date('2023-09-01'))"}&lt;SPAN&gt;&amp;gt;} Sales)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 18:30:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-Analysis-Question-DateField1-gt-DateField2/m-p/2158709#M93918</guid>
      <dc:creator>Brysonds</dc:creator>
      <dc:date>2024-01-05T18:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis Question - DateField1 &gt;= DateField2</title>
      <link>https://community.qlik.com/t5/App-Development/Set-Analysis-Question-DateField1-gt-DateField2/m-p/2158728#M93924</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;It's important to realize that Set Analysis conditions are evaluated outside of your chart expressions, and hence you should formulate a condition that is "universal", or independent of your chart dimensions.&lt;/P&gt;
&lt;P&gt;Also, your Set Analysis filters should be formulated correctly, to filter the correct data elements. In your case, you are not selecting Date1 values that are greater than Date2 values - that would give you the wrong result obviously. You are trying to select &lt;EM&gt;Sales&amp;nbsp;&lt;/EM&gt;for those rows of data where Date1&amp;gt;=Date2 (I presume that both dates reside in the same fact table).&amp;nbsp; With that in mind, a Set Analysis filter could look like this:&lt;BR /&gt;&lt;BR /&gt;Sum( {&amp;lt;Sales = {"=DateField1&amp;gt;=DateFIeld2"}&amp;nbsp; &amp;nbsp;&amp;gt;}&amp;nbsp; Sales)&lt;/P&gt;
&lt;P&gt;Word of caution: in a relatively large data set, this will be extremely heavy! A lot heavier than using the dreaded IF function. So, you might find that an easier formula could work a lot faster:&lt;BR /&gt;&lt;BR /&gt;Sum( IF(DateField1&amp;gt;=DateField2, Sales))&lt;BR /&gt;&lt;BR /&gt;Ultimately the best performance could be achieved by adding a conditional flag field to your data, that would store the result of the date comparison:&lt;BR /&gt;&lt;BR /&gt;LOAD&lt;BR /&gt;...&lt;BR /&gt;IF(DateField1&amp;gt;=DateField2, 1, 0)&amp;nbsp; &amp;nbsp; as _DateFlag&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;and then your Set Analysis could be extremely simple, and it would work very fast:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Sum( {&amp;lt;_DateFlag={1}&amp;nbsp;&amp;gt;}&amp;nbsp; Sales)&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 20:07:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-Analysis-Question-DateField1-gt-DateField2/m-p/2158728#M93924</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2024-01-05T20:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis Question - DateField1 &gt;= DateField2</title>
      <link>https://community.qlik.com/t5/App-Development/Set-Analysis-Question-DateField1-gt-DateField2/m-p/2158754#M93927</link>
      <description>&lt;P&gt;Thank you for the detailed response, this really helped me better understand how this was working. All of the proposed solutions worked!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 21:23:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-Analysis-Question-DateField1-gt-DateField2/m-p/2158754#M93927</guid>
      <dc:creator>Brysonds</dc:creator>
      <dc:date>2024-01-05T21:23:04Z</dc:date>
    </item>
  </channel>
</rss>

