<?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 AutoNumber(RowNo(),[MyField]) takes too long in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/AutoNumber-RowNo-MyField-takes-too-long/m-p/1815014#M66660</link>
    <description>&lt;P&gt;I'm using AutoNumber(RowNo(),[MyField]) and it takes 25 minutes with 800k rows and I'm only going to have more as time goes by. (In SQL I'd use Row_Number() over Partition By, but I can't use that here.) How can I accomplish the same thing in substantially less time?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a Load Script that does what I want with some fake data. The point is to have a column that numbers the rows in which a patient visit took place in multiple departments on the same day. For example, a patient is admitted to the Emergency Department (ED) and transferred to the ICU. The ED row is '1', the ICU row is '2'. How can I do this for lots of data very quickly?&lt;/P&gt;&lt;P&gt;TempTable2:&lt;BR /&gt;LOAD * INLINE&lt;BR /&gt;[VisitNum, Dept, Date,&lt;BR /&gt;1000, ED, 2021-06-10&lt;BR /&gt;1001, ED, 2021-06-10&lt;BR /&gt;1001, ICU, 2021-06-10&lt;BR /&gt;1002, MedSurg, 2021-06-11&lt;BR /&gt;1003, ICU, 2021-06-10&lt;BR /&gt;1003, MedSurg, 2021-06-11&lt;BR /&gt;1004, ED, 2021-06-11&lt;BR /&gt;1004, MedSurg, 2021-06-11&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;TempTable1:&lt;BR /&gt;LOAD&lt;BR /&gt;*,&lt;BR /&gt;(VisitNum &amp;amp; '-' &amp;amp; Date) as PatientDayPresent&lt;BR /&gt;Resident TempTable2&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;DayPresent:&lt;BR /&gt;Load DISTINCT&lt;BR /&gt;*&lt;BR /&gt;,AutoNumber(RowNo(),PatientDayPresent) as PatientDayPresentIndex&lt;BR /&gt;Resident TempTable1;&lt;/P&gt;&lt;P&gt;Drop Tables TempTable2, TempTable1;&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jun 2021 19:30:50 GMT</pubDate>
    <dc:creator>Margaret</dc:creator>
    <dc:date>2021-06-14T19:30:50Z</dc:date>
    <item>
      <title>AutoNumber(RowNo(),[MyField]) takes too long</title>
      <link>https://community.qlik.com/t5/App-Development/AutoNumber-RowNo-MyField-takes-too-long/m-p/1815014#M66660</link>
      <description>&lt;P&gt;I'm using AutoNumber(RowNo(),[MyField]) and it takes 25 minutes with 800k rows and I'm only going to have more as time goes by. (In SQL I'd use Row_Number() over Partition By, but I can't use that here.) How can I accomplish the same thing in substantially less time?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a Load Script that does what I want with some fake data. The point is to have a column that numbers the rows in which a patient visit took place in multiple departments on the same day. For example, a patient is admitted to the Emergency Department (ED) and transferred to the ICU. The ED row is '1', the ICU row is '2'. How can I do this for lots of data very quickly?&lt;/P&gt;&lt;P&gt;TempTable2:&lt;BR /&gt;LOAD * INLINE&lt;BR /&gt;[VisitNum, Dept, Date,&lt;BR /&gt;1000, ED, 2021-06-10&lt;BR /&gt;1001, ED, 2021-06-10&lt;BR /&gt;1001, ICU, 2021-06-10&lt;BR /&gt;1002, MedSurg, 2021-06-11&lt;BR /&gt;1003, ICU, 2021-06-10&lt;BR /&gt;1003, MedSurg, 2021-06-11&lt;BR /&gt;1004, ED, 2021-06-11&lt;BR /&gt;1004, MedSurg, 2021-06-11&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;TempTable1:&lt;BR /&gt;LOAD&lt;BR /&gt;*,&lt;BR /&gt;(VisitNum &amp;amp; '-' &amp;amp; Date) as PatientDayPresent&lt;BR /&gt;Resident TempTable2&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;DayPresent:&lt;BR /&gt;Load DISTINCT&lt;BR /&gt;*&lt;BR /&gt;,AutoNumber(RowNo(),PatientDayPresent) as PatientDayPresentIndex&lt;BR /&gt;Resident TempTable1;&lt;/P&gt;&lt;P&gt;Drop Tables TempTable2, TempTable1;&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 19:30:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/AutoNumber-RowNo-MyField-takes-too-long/m-p/1815014#M66660</guid>
      <dc:creator>Margaret</dc:creator>
      <dc:date>2021-06-14T19:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: AutoNumber(RowNo(),[MyField]) takes too long</title>
      <link>https://community.qlik.com/t5/App-Development/AutoNumber-RowNo-MyField-takes-too-long/m-p/1815069#M66667</link>
      <description>&lt;P&gt;AutoNumber can be slow when you have lots of distinct AutoId values. A faster alternative can be to use Previous() and Peek() to process an ordered table.&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s1"&gt;TempTable2:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;LOAD&lt;/SPAN&gt;&lt;SPAN class="s1"&gt; *, &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;RecNo&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;() &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;as&lt;/SPAN&gt; RecId &lt;SPAN class="s2"&gt;INLINE&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;[VisitNum, Dept, Date,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1000, ED, 2021-06-10&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1001, ED, 2021-06-10&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1001, ICU, 2021-06-10&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1002, MedSurg, 2021-06-11&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1003, ICU, 2021-06-10&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1003, MedSurg, 2021-06-11&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1004, ED, 2021-06-11&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1004, MedSurg, 2021-06-11&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;]&lt;SPAN class="s1"&gt;;&lt;BR /&gt;&lt;BR /&gt;DayPresent:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;LOAD&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;*,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;if&lt;/SPAN&gt;&lt;SPAN class="s1"&gt; (&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Previous&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;(&lt;/SPAN&gt;VisitNum&lt;SPAN class="s1"&gt;) = &lt;/SPAN&gt;VisitNum &lt;SPAN class="s2"&gt;and&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;Previous&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;(&lt;/SPAN&gt;Date&lt;SPAN class="s1"&gt;) = &lt;/SPAN&gt;Date&lt;SPAN class="s1"&gt;, &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;peek&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;('PatientDayPresentIndex') + 1, 1) &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;as&lt;/SPAN&gt; PatientDayPresentIndex&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Resident&lt;/SPAN&gt;&lt;SPAN class="s1"&gt; TempTable2&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Order&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;by&lt;/SPAN&gt; VisitNum&lt;SPAN class="s1"&gt;, &lt;/SPAN&gt;Date&lt;SPAN class="s1"&gt;, &lt;/SPAN&gt;RecId&lt;SPAN class="s1"&gt;&lt;BR /&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Drop&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;Table&lt;/SPAN&gt;&lt;SPAN class="s1"&gt; TempTable2;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Note I assigned a "recId" in the initial load as a way of maintaining the order of the intra-day events.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;-Rob&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 04:30:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/AutoNumber-RowNo-MyField-takes-too-long/m-p/1815069#M66667</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2021-06-15T04:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: AutoNumber(RowNo(),[MyField]) takes too long</title>
      <link>https://community.qlik.com/t5/App-Development/AutoNumber-RowNo-MyField-takes-too-long/m-p/1815335#M66704</link>
      <description>&lt;P&gt;Thank you, that worked!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 20:00:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/AutoNumber-RowNo-MyField-takes-too-long/m-p/1815335#M66704</guid>
      <dc:creator>Margaret</dc:creator>
      <dc:date>2021-06-15T20:00:48Z</dc:date>
    </item>
  </channel>
</rss>

