<?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: Create new item (position) field in script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751851#M57889</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46967"&gt;@jorditorras&lt;/a&gt;&amp;nbsp; like ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if(rowno()=1,1,if(peek("Order")="Order",peek([Position Line])+1,1)) as [Position Line]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;load *,if(rowno()=1,1,if(peek("Order")="Order",peek([Position Line])+1,1)) as [Position Line] inline [
Order
OR001
OR001
OR002
OR003
OR003
OR003
];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 358px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/42135i0E159FED15E11CD4/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;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Oct 2020 08:31:14 GMT</pubDate>
    <dc:creator>Taoufiq_Zarra</dc:creator>
    <dc:date>2020-10-13T08:31:14Z</dc:date>
    <item>
      <title>Create new item (position) field in script</title>
      <link>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751830#M57885</link>
      <description>&lt;P&gt;Hi Gurús,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data model based on information of orders where I have one record per order (I was counting orders doing&amp;nbsp; "1 as ordercounter"). However now I'm doing a left join to another table and now I have multiple records per order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to create in the script an extra field (something like a "position line") that generate a position counter. Something like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Order&amp;nbsp; &amp;nbsp; &amp;nbsp; Position Line&lt;/P&gt;&lt;P&gt;OR001&amp;nbsp; &amp;nbsp; 001&lt;/P&gt;&lt;P&gt;OR001&amp;nbsp; &amp;nbsp; 002&lt;/P&gt;&lt;P&gt;OR002&amp;nbsp; &amp;nbsp; 001&lt;/P&gt;&lt;P&gt;OR003&amp;nbsp; &amp;nbsp; 001&lt;/P&gt;&lt;P&gt;OR003&amp;nbsp; &amp;nbsp; 002&lt;/P&gt;&lt;P&gt;OR003&amp;nbsp; &amp;nbsp; 003&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Any idea of how I can generate this field "Position Line"?&lt;/P&gt;&lt;P&gt;Thank you very much!!!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 21:08:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751830#M57885</guid>
      <dc:creator>jorditorras</dc:creator>
      <dc:date>2021-12-20T21:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create new item (position) field in script</title>
      <link>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751848#M57888</link>
      <description>&lt;P&gt;You could try something like I've done in my script below.&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;TMP:
LOAD * inline [
Order, OrderDate
OR001, 2020-10-10
OR002, 2020-10-12
OR003, 2020-10-13
OR004, 2020-10-13];

LEFT JOIN 
LOAD * inline [
Order, Article, Qty
OR001, Apple, 	100
OR001, Orange,	90
OR002, Apple,	200
OR002, Orange,  250
OR003, Pineapple, 50
OR003, Orange,  300
OR003, Banana,	125
OR004, Banana,  260
];

Final:
LOAD 
	Order,
	OrderDate, 
	Article, 
	Qty,
	if(peek('Order')=Order, num(Peek('Position Line')+1, '000'), 001) as [Position Line]
Resident TMP
Order By Order;
DROP TABLE TMP;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 13 Oct 2020 08:24:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751848#M57888</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2020-10-13T08:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create new item (position) field in script</title>
      <link>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751851#M57889</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46967"&gt;@jorditorras&lt;/a&gt;&amp;nbsp; like ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if(rowno()=1,1,if(peek("Order")="Order",peek([Position Line])+1,1)) as [Position Line]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;load *,if(rowno()=1,1,if(peek("Order")="Order",peek([Position Line])+1,1)) as [Position Line] inline [
Order
OR001
OR001
OR002
OR003
OR003
OR003
];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 358px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/42135i0E159FED15E11CD4/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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 08:31:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751851#M57889</guid>
      <dc:creator>Taoufiq_Zarra</dc:creator>
      <dc:date>2020-10-13T08:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create new item (position) field in script</title>
      <link>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751911#M57897</link>
      <description>&lt;P&gt;Thank you so much!! That works perfectly!!!!!!!!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 11:08:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1751911#M57897</guid>
      <dc:creator>jorditorras</dc:creator>
      <dc:date>2020-10-13T11:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create new item (position) field in script</title>
      <link>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1752046#M57913</link>
      <description>&lt;P&gt;I'm seeing that it's not working for all the records.... There are some specific orders with duplicated "Position Lines":&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jorditorras_0-1602598569715.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/42162iA7395A1A3635FE81/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jorditorras_0-1602598569715.png" alt="jorditorras_0-1602598569715.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 14:18:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1752046#M57913</guid>
      <dc:creator>jorditorras</dc:creator>
      <dc:date>2020-10-13T14:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create new item (position) field in script</title>
      <link>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1752158#M57926</link>
      <description>&lt;P&gt;Now it's done. I was just missing Vegas suggestion of Orderding by Order. Thanks to both!!!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:06:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-new-item-position-field-in-script/m-p/1752158#M57926</guid>
      <dc:creator>jorditorras</dc:creator>
      <dc:date>2020-10-13T19:06:08Z</dc:date>
    </item>
  </channel>
</rss>

