<?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 Max value for start date when two conditions macthed in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2418247#M95409</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm trying to finalize a setAnalysis without success so far.&lt;BR /&gt;I have got two tables (THINGS and THINGS_STATES with a common id (ID_THING)).&lt;/P&gt;
&lt;P&gt;A THING can have many states. The table contains the following fields:&lt;BR /&gt;-ID_THING&lt;BR /&gt;-THING_START_DATE&lt;BR /&gt;-THING_END_DATE&lt;BR /&gt;-THING_STATUS (2 possible values : ACTIVE or INACTIVE&lt;/P&gt;
&lt;P&gt;I would like to count only the THINGS :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Start date before AND end date after vDateMax&lt;/LI&gt;
&lt;LI&gt;OR Start date before vDateMax AND Status = Active&lt;EM&gt; (or End date is null)&lt;/EM&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I've built this setAnalysis:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;count( distinct {
&amp;lt; [THING_START_DATE] = {"&amp;lt;=$(=DATE([vDateMax]))"} , [THING_END_DATE] = {"&amp;gt;=$(=DATE([vDateMax]))"}&amp;gt;
+
&amp;lt; [THING_START_DATE] = {"&amp;lt;=$(=DATE([vDateMax]))"}, THING_STATUS = {'ACTIVE'}&amp;gt;
}
aggr(max([THING_START_DATE]),ID_THING))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;vDateMax is a var set from a date selected by the user.&lt;/P&gt;
&lt;P&gt;The ending AGGR was meant to keep only the max THING START DATE when a THING has one status starting at the same date as its previous status ending date.&lt;/P&gt;
&lt;P&gt;How can I achieve this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
    <pubDate>Tue, 20 Feb 2024 07:40:57 GMT</pubDate>
    <dc:creator>VincentD1</dc:creator>
    <dc:date>2024-02-20T07:40:57Z</dc:date>
    <item>
      <title>Max value for start date when two conditions macthed</title>
      <link>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2418247#M95409</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm trying to finalize a setAnalysis without success so far.&lt;BR /&gt;I have got two tables (THINGS and THINGS_STATES with a common id (ID_THING)).&lt;/P&gt;
&lt;P&gt;A THING can have many states. The table contains the following fields:&lt;BR /&gt;-ID_THING&lt;BR /&gt;-THING_START_DATE&lt;BR /&gt;-THING_END_DATE&lt;BR /&gt;-THING_STATUS (2 possible values : ACTIVE or INACTIVE&lt;/P&gt;
&lt;P&gt;I would like to count only the THINGS :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Start date before AND end date after vDateMax&lt;/LI&gt;
&lt;LI&gt;OR Start date before vDateMax AND Status = Active&lt;EM&gt; (or End date is null)&lt;/EM&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I've built this setAnalysis:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;count( distinct {
&amp;lt; [THING_START_DATE] = {"&amp;lt;=$(=DATE([vDateMax]))"} , [THING_END_DATE] = {"&amp;gt;=$(=DATE([vDateMax]))"}&amp;gt;
+
&amp;lt; [THING_START_DATE] = {"&amp;lt;=$(=DATE([vDateMax]))"}, THING_STATUS = {'ACTIVE'}&amp;gt;
}
aggr(max([THING_START_DATE]),ID_THING))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;vDateMax is a var set from a date selected by the user.&lt;/P&gt;
&lt;P&gt;The ending AGGR was meant to keep only the max THING START DATE when a THING has one status starting at the same date as its previous status ending date.&lt;/P&gt;
&lt;P&gt;How can I achieve this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 07:40:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2418247#M95409</guid>
      <dc:creator>VincentD1</dc:creator>
      <dc:date>2024-02-20T07:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Max value for start date when two conditions macthed</title>
      <link>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2418255#M95410</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/205204"&gt;@VincentD1&lt;/a&gt;&amp;nbsp;How is the validation for the expression? Is this Ended OK with variable result as it should? or any error.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 13:45:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2418255#M95410</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2024-02-13T13:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Max value for start date when two conditions macthed</title>
      <link>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2418362#M95414</link>
      <description>&lt;P&gt;Could you try to put your set analysis in the MAX too?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 15:44:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2418362#M95414</guid>
      <dc:creator>vincent_ardiet_</dc:creator>
      <dc:date>2024-02-13T15:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Max value for start date when two conditions macthed</title>
      <link>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2421012#M95678</link>
      <description>&lt;P&gt;The expression was almost correct.&lt;/P&gt;
&lt;P&gt;In fact, it was the "distinct" at the beginning of the SetAnalysis that was an error since it excluded THINGS that had the same THING_START_DATE.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 07:40:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Max-value-for-start-date-when-two-conditions-macthed/m-p/2421012#M95678</guid>
      <dc:creator>VincentD1</dc:creator>
      <dc:date>2024-02-20T07:40:27Z</dc:date>
    </item>
  </channel>
</rss>

