<?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 expression - calculation based on state and id in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1743107#M56943</link>
    <description>&lt;P&gt;So, you can try one of the two&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sum(Aggr(
  If(FirstSortedValue(State, -TimeStampField) = 'Active', 1, 0)
, Id))

or

Count(DISTINCT {&amp;lt;Id = {"=FirstSortedValue(State, -TimeStampField) = 'Active'}&amp;gt;} Id)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Sep 2020 11:22:52 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2020-09-11T11:22:52Z</dc:date>
    <item>
      <title>Set expression - calculation based on state and id</title>
      <link>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1742961#M56913</link>
      <description>&lt;P&gt;Hi guys, Could please help,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could not build set expressions to calculate in the table only last state 'Active' when after was none State 'New' based on week date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE width="233px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="40px" height="47px"&gt;Id&amp;nbsp;&lt;/TD&gt;&lt;TD width="55px" height="47px"&gt;State&lt;/TD&gt;&lt;TD width="83px" height="47px"&gt;Set expression&lt;/TD&gt;&lt;TD width="55px" height="47px"&gt;Date&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;Active&lt;/TD&gt;&lt;TD width="83px" height="25px"&gt;0&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;week1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;New&lt;/TD&gt;&lt;TD width="83px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;week1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;3&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;Active&amp;nbsp;&lt;/TD&gt;&lt;TD width="83px" height="25px"&gt;0&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;week2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;3&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;New&lt;/TD&gt;&lt;TD width="83px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;week2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;5&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;New&lt;/TD&gt;&lt;TD width="83px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;week3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px" height="25px"&gt;5&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;Active&lt;/TD&gt;&lt;TD width="83px" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="55px" height="25px"&gt;week3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result should be 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;Could you please take a look&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46628"&gt;@sunny_talwar&lt;/a&gt;&amp;nbsp;?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 18:28:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1742961#M56913</guid>
      <dc:creator>Micki</dc:creator>
      <dc:date>2021-12-23T18:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Set expression - calculation based on state and id</title>
      <link>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1742962#M56914</link>
      <description>&lt;P&gt;How do you determine if Active came first or New? Id and Date (week) seems to be same for both Active and New rows?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 20:52:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1742962#M56914</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2020-09-10T20:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Set expression - calculation based on state and id</title>
      <link>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1743003#M56918</link>
      <description>&lt;P&gt;Hi, sorry i didn't mention that instead of date i have Timestamp, so I sorted by ID + THEN week number based on Timestamp&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2020 06:22:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1743003#M56918</guid>
      <dc:creator>Micki</dc:creator>
      <dc:date>2020-09-11T06:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Set expression - calculation based on state and id</title>
      <link>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1743107#M56943</link>
      <description>&lt;P&gt;So, you can try one of the two&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sum(Aggr(
  If(FirstSortedValue(State, -TimeStampField) = 'Active', 1, 0)
, Id))

or

Count(DISTINCT {&amp;lt;Id = {"=FirstSortedValue(State, -TimeStampField) = 'Active'}&amp;gt;} Id)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2020 11:22:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-expression-calculation-based-on-state-and-id/m-p/1743107#M56943</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2020-09-11T11:22:52Z</dc:date>
    </item>
  </channel>
</rss>

