<?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: Calc Last and First data in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1977853#M80709</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6846"&gt;@spividori&lt;/a&gt;&amp;nbsp; Please look at the Script used in the back end. Have a look at it and let me know if this something that you are looking for:&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;BR /&gt;Temp:&lt;BR /&gt;Load IdAnimal,&lt;BR /&gt;Date(Date#(Date,'DD/MM/YYYY'),'MM/DD/YYYY') as Date,&lt;BR /&gt;Peso&lt;BR /&gt;Inline [&lt;BR /&gt;IdAnimal, Date, Peso&lt;BR /&gt;30695,13/05/2021,500&lt;BR /&gt;30695,19/08/2021,259&lt;BR /&gt;30695,22/09/2021,370&lt;BR /&gt;30695,03/12/2021,346&lt;BR /&gt;30695,02/08/2022,414&lt;BR /&gt;30772,21/01/2021,314&lt;BR /&gt;30772,15/04/2021,403&lt;BR /&gt;30772,29/06/2021,436&lt;BR /&gt;30772,19/08/2021,432&lt;BR /&gt;30772,15/10/2021,465&lt;BR /&gt;30772,25/11/2021,469&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;BR /&gt;Temp1:&lt;BR /&gt;Load IdAnimal,&lt;BR /&gt;&lt;BR /&gt;FirstSortedValue(Peso,Date) as FirstValue,&lt;BR /&gt;FirstSortedValue(Peso,-Date) as lastValue&lt;/P&gt;
&lt;P&gt;Resident Temp&lt;BR /&gt;group by IdAnimal;&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;BR /&gt;Temp2:&lt;BR /&gt;Load IdAnimal,&lt;BR /&gt;FirstValue,&lt;BR /&gt;lastValue,&lt;BR /&gt;lastValue-FirstValue as Difference&lt;/P&gt;
&lt;P&gt;Resident Temp1;&lt;/P&gt;
&lt;P&gt;Drop table Temp,Temp1;&lt;/P&gt;
&lt;P&gt;Exit Script;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sidhiq91_0-1662516932109.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/88466i000AC91038AF4244/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sidhiq91_0-1662516932109.png" alt="sidhiq91_0-1662516932109.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Sep 2022 02:16:04 GMT</pubDate>
    <dc:creator>sidhiq91</dc:creator>
    <dc:date>2022-09-07T02:16:04Z</dc:date>
    <item>
      <title>Calc Last and First data</title>
      <link>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1977828#M80706</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;I have the following table and I need to calculate the last "Peso" - the first "Peso" of each IdAnimal in a KPI. This has to be dynamic. In the first example I have selected the years 2021 and 2022 and in the second example I only have the year 2021 selected.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Captura.PNG" style="width: 543px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/88462i7C9020D6978F158A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Captura.PNG" alt="Captura.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Captura2.PNG" style="width: 550px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/88463i2045A37A85174CB4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Captura2.PNG" alt="Captura2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 23:55:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1977828#M80706</guid>
      <dc:creator>spividori</dc:creator>
      <dc:date>2022-09-06T23:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Last and First data</title>
      <link>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1977853#M80709</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6846"&gt;@spividori&lt;/a&gt;&amp;nbsp; Please look at the Script used in the back end. Have a look at it and let me know if this something that you are looking for:&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;BR /&gt;Temp:&lt;BR /&gt;Load IdAnimal,&lt;BR /&gt;Date(Date#(Date,'DD/MM/YYYY'),'MM/DD/YYYY') as Date,&lt;BR /&gt;Peso&lt;BR /&gt;Inline [&lt;BR /&gt;IdAnimal, Date, Peso&lt;BR /&gt;30695,13/05/2021,500&lt;BR /&gt;30695,19/08/2021,259&lt;BR /&gt;30695,22/09/2021,370&lt;BR /&gt;30695,03/12/2021,346&lt;BR /&gt;30695,02/08/2022,414&lt;BR /&gt;30772,21/01/2021,314&lt;BR /&gt;30772,15/04/2021,403&lt;BR /&gt;30772,29/06/2021,436&lt;BR /&gt;30772,19/08/2021,432&lt;BR /&gt;30772,15/10/2021,465&lt;BR /&gt;30772,25/11/2021,469&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;BR /&gt;Temp1:&lt;BR /&gt;Load IdAnimal,&lt;BR /&gt;&lt;BR /&gt;FirstSortedValue(Peso,Date) as FirstValue,&lt;BR /&gt;FirstSortedValue(Peso,-Date) as lastValue&lt;/P&gt;
&lt;P&gt;Resident Temp&lt;BR /&gt;group by IdAnimal;&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;BR /&gt;Temp2:&lt;BR /&gt;Load IdAnimal,&lt;BR /&gt;FirstValue,&lt;BR /&gt;lastValue,&lt;BR /&gt;lastValue-FirstValue as Difference&lt;/P&gt;
&lt;P&gt;Resident Temp1;&lt;/P&gt;
&lt;P&gt;Drop table Temp,Temp1;&lt;/P&gt;
&lt;P&gt;Exit Script;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sidhiq91_0-1662516932109.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/88466i000AC91038AF4244/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sidhiq91_0-1662516932109.png" alt="sidhiq91_0-1662516932109.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 02:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1977853#M80709</guid>
      <dc:creator>sidhiq91</dc:creator>
      <dc:date>2022-09-07T02:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Last and First data</title>
      <link>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1977857#M80710</link>
      <description>&lt;P&gt;May be in the front-end like this -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Digvijay_Singh_0-1662517163192.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/88467i7AB498B5DFDC40C1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Digvijay_Singh_0-1662517163192.png" alt="Digvijay_Singh_0-1662517163192.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 02:19:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1977857#M80710</guid>
      <dc:creator>Digvijay_Singh</dc:creator>
      <dc:date>2022-09-07T02:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Last and First data</title>
      <link>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1978123#M80741</link>
      <description>&lt;P&gt;Thanks for answering.&lt;BR /&gt;The total by IdAnimal is correct but I need the general total to be the sum of the result of each IdAnimal. in the example of the image it should be: 69, not 100.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Captura.PNG" style="width: 610px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/88510i9E45DA5B5478B948/image-size/large?v=v2&amp;amp;px=999" role="button" title="Captura.PNG" alt="Captura.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 13:27:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1978123#M80741</guid>
      <dc:creator>spividori</dc:creator>
      <dc:date>2022-09-07T13:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Last and First data</title>
      <link>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1978147#M80744</link>
      <description>&lt;P&gt;Try changing this property to sum -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Digvijay_Singh_0-1662558732498.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/88515i6C39C413C2E3B4DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Digvijay_Singh_0-1662558732498.png" alt="Digvijay_Singh_0-1662558732498.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;OR expression to as below -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sum(Aggr(FirstSortedValue(Peso,-FechaEvPS)-FirstSortedValue(Peso,FechaEvPS),IdAnimal))&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 13:53:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1978147#M80744</guid>
      <dc:creator>Digvijay_Singh</dc:creator>
      <dc:date>2022-09-07T13:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Last and First data</title>
      <link>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1978184#M80747</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;Yes. It's what I needed. Thank you very much!.&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 14:53:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calc-Last-and-First-data/m-p/1978184#M80747</guid>
      <dc:creator>spividori</dc:creator>
      <dc:date>2022-09-07T14:53:16Z</dc:date>
    </item>
  </channel>
</rss>

