<?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: Generate next value based on the previous value in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666987#M50263</link>
    <description>&lt;P&gt;would you be able to share sample data?&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jan 2020 11:15:57 GMT</pubDate>
    <dc:creator>Kushal_Chawda</dc:creator>
    <dc:date>2020-01-18T11:15:57Z</dc:date>
    <item>
      <title>Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666867#M50239</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have the following issue if anyone can help with it, please.&lt;/P&gt;&lt;P&gt;i have a list of PCK numbers: as shown in table below. I want to generate something similar to the table below. My only issue is the first column. Suppose that i have the first number, how do i use the previous rows number and add 10 to it to make the next number. So, for example, my first number is 40 and for the first row i use 40+10=50. For the next iteration, i want to use 50+10=60 and so on. It is like iterative calculation using the value i pass in.&lt;/P&gt;&lt;P&gt;the number 40 is taken from another table. It is the max "Sort Number" in another table. so I use Peek() to obtain the max number from that table. Now i want to generate a separate table with the PCK list i have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you are unsure of what i am trying to ask.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SortNumber&lt;/TD&gt;&lt;TD&gt;PN&lt;/TD&gt;&lt;TD&gt;Indicator&lt;/TD&gt;&lt;TD&gt;PCK&lt;/TD&gt;&lt;TD&gt;GCK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;50&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;TD&gt;R444&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;60&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;TD&gt;T3233&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;70&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;TD&gt;Y351&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;80&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;TD&gt;R2331&lt;/TD&gt;&lt;TD&gt;*&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 19:17:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666867#M50239</guid>
      <dc:creator>waleeed_mahmood</dc:creator>
      <dc:date>2024-11-16T19:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666876#M50243</link>
      <description>&lt;P&gt;Set vFirstNumber = the max "Sort Number" from another table, then use this script:&lt;/P&gt;&lt;LI-CODE lang="java"&gt;LOAD 
	PCK
	,if(RowNo()=1,$(vFirstNumber),Peek('SortNumber'))+10 as SortNumber
Resident [your data];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;It uses RowNo() to check if it is loading the first row. If so, it uses the vFirstNumber variable you set earlier (should be 40). After the first row, the table will load the previous SortNumber instead of using vFirstNumber.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 17:31:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666876#M50243</guid>
      <dc:creator>gavinlaird</dc:creator>
      <dc:date>2020-01-17T17:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666947#M50256</link>
      <description>&lt;P&gt;Hey Gavin,&lt;/P&gt;&lt;P&gt;Thank you for the quick reply.&amp;nbsp; I just have one question&lt;/P&gt;&lt;PRE&gt;if(RowNo()=1,$(vFirstNumber),Peek('&lt;FONT color="#FF0000"&gt;SortNumber&lt;/FONT&gt;'))+10 as &lt;FONT color="#FF0000"&gt;SortNumber&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;in the above code, you have Peek('SortNumber' ) and you are also assigning the column "as SortNumber". are you referencing the same column? or in different words, are both SortNumber colored red the same thing?&lt;/P&gt;&lt;P&gt;Also, i tried it and it is giving me null values&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 21:32:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666947#M50256</guid>
      <dc:creator>waleeed_mahmood</dc:creator>
      <dc:date>2020-01-17T21:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666950#M50258</link>
      <description>&lt;P&gt;Yes, it is referencing the same "SortNumber" column. That is why the first part of the expression is required- "if(RowNo()=1" checks to see if it is loading the first row (in which case, there would be no "SortNumber" field yet to reference with Peek). For the first row, it uses $(vFirstNumber), rather than Peek('SortNumber'). For all rows after that, it uses Peek('SortNumber') since the "SortNumber" field exists at that point.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 21:32:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666950#M50258</guid>
      <dc:creator>gavinlaird</dc:creator>
      <dc:date>2020-01-17T21:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666952#M50259</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="I am getting the following result using your code" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/27108i00628BACCA88A23D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="I am getting the following result using your code" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;I am getting the following result using your code&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 21:34:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666952#M50259</guid>
      <dc:creator>waleeed_mahmood</dc:creator>
      <dc:date>2020-01-17T21:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666953#M50260</link>
      <description>&lt;P&gt;I can troubleshoot if you post your load script&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 21:48:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666953#M50260</guid>
      <dc:creator>gavinlaird</dc:creator>
      <dc:date>2020-01-17T21:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666954#M50261</link>
      <description>&lt;P&gt;Another would be to have your load script this way assuming you have your starting number assigned to a variable called "vStartingNum".&amp;nbsp; I tested this in September 2019 release and it returns 6 rows with IDs 50-100 progressing by 10s.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table1:&lt;BR /&gt;LOAD *&lt;BR /&gt;INLINE [&lt;BR /&gt;SomeNumber&lt;BR /&gt;40&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;let vStartingNum = Peek('SomeNumber', 0, 'Table1');&lt;/P&gt;&lt;P&gt;Trace $(vStartingNum);&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;BR /&gt;Table2:&lt;BR /&gt;LOAD *&lt;BR /&gt;INLINE [&lt;BR /&gt;SomeOtherData&lt;BR /&gt;asdfa&lt;BR /&gt;sdfghdhrr&lt;BR /&gt;mrsrm3&lt;BR /&gt;mrytdmth&lt;BR /&gt;mydf&lt;BR /&gt;mhgmdgh&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Table3:&lt;BR /&gt;Load SomeOtherData, BaseNumber+(RowNo()*10) as Rownumber;&lt;BR /&gt;LOAD SomeOtherData, '$(vStartingNum)' as BaseNumber&lt;BR /&gt;Resident Table2;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Drop Table Table2;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 22:33:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666954#M50261</guid>
      <dc:creator>andoryuu</dc:creator>
      <dc:date>2020-01-17T22:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666956#M50262</link>
      <description>&lt;LI-CODE lang="php"&gt;let vSortNumber = Peek('Sort Number',-1,'Derivation_Rule_Table'); //8640
 
 Temp:
 
 Load *,
 if(RowNo()=1,$(vSortNumber),Peek('SortNumber'))+10 as SortNumber,
 ;
 Load Distinct(FGCK) as GCKs //there are only 9 distinct GCK values
 Resident Material_Master_Table
 Where IsNull(LINKTORULE) OR Len(Trim(LINKTORULE))=0;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result of this is as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 347px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/27109iDC4C87243999AE75/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;it took away the distinct GCKs and duplicated it over and over again(thousands of records). I am expecting only 9 rows starting from 8650 til 8740 as sort number since there are only 9 distinct GCKs. the above snippet actually starts from 8650 til 25480 (shown above)&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 22:53:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666956#M50262</guid>
      <dc:creator>waleeed_mahmood</dc:creator>
      <dc:date>2020-01-17T22:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666987#M50263</link>
      <description>&lt;P&gt;would you be able to share sample data?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 11:15:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1666987#M50263</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-01-18T11:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1667029#M50273</link>
      <description>&lt;P&gt;Hello Kush,&lt;/P&gt;&lt;P&gt;for sure. I have the following GCK values:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 158px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/27121i1DAF9CF9E9A69B49/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and what is want is the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 964px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/27122i38C452D8AA8F8C46/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For each of the GCK values, i want ONE ROW only. with the values similar to above ( which i can hard code into the script). the only issue is getting a number that is the incremented by 10 from the previous value. So, in the case above, first value is 8650, 8660,8670,8680 and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 22:59:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1667029#M50273</guid>
      <dc:creator>waleeed_mahmood</dc:creator>
      <dc:date>2020-01-18T22:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Generate next value based on the previous value</title>
      <link>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1667030#M50274</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;SPAN class=""&gt;&lt;A href="https://community.qlik.com/t5/user/viewprofilepage/user-id/3607" target="_self"&gt;Andoryuu&lt;/A&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I will apply your code to my script and let you know. So far, it looks promising.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 23:01:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Generate-next-value-based-on-the-previous-value/m-p/1667030#M50274</guid>
      <dc:creator>waleeed_mahmood</dc:creator>
      <dc:date>2020-01-18T23:01:35Z</dc:date>
    </item>
  </channel>
</rss>

