<?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: Storing data into multiple files based on the line items in an account in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2521044#M106493</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/293209"&gt;@qliksenseadminthomascook&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 - Load your data&lt;/P&gt;&lt;P&gt;2 - Create a column ID with RecNo()&amp;nbsp; ( it will be filled with the number of the row )&amp;nbsp;&lt;/P&gt;&lt;P&gt;3 - Create a new column FileNumber&amp;nbsp; - &amp;gt; ID / 400.000 (it will generate a new column with divisor number)&amp;nbsp;&lt;/P&gt;&lt;P&gt;4 - Peek the minimum and maximum value of&amp;nbsp; FileNumber&lt;/P&gt;&lt;P&gt;5 - Create a for statement for i = Min to Max and store your files&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;[sales_data_sample]:&lt;/DIV&gt;&lt;DIV&gt;LOAD&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[ORDERNUMBER],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[QUANTITYORDERED],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[PRICEEACH],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[ORDERLINENUMBER],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[SALES],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RowNo() as ID,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Floor(RowNo()&amp;nbsp; / 1000) as FileNumber&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;FROM [lib://Downloads/sales_data_sample.csv]&lt;/DIV&gt;&lt;DIV&gt;(txt, codepage is 1252, embedded labels, delimiter is ',', msq);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Temp:&lt;/DIV&gt;&lt;DIV&gt;Load&amp;nbsp; Min(FileNumber) as MinFile&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;,Max(FileNumber) as MaxFile&lt;/DIV&gt;&lt;DIV&gt;Resident sales_data_sample;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Let vMin = Peek('MinFile',0,'Temp') ;&lt;/DIV&gt;&lt;DIV&gt;Let vMax = Peek('MaxFile',0,'Temp') ;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Drop table&amp;nbsp;Temp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;trace =================;&lt;/DIV&gt;&lt;DIV&gt;trace $(vMin) - $(vMax);&lt;/DIV&gt;&lt;DIV&gt;trace =================;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;for i = vMin to vMax&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; temp:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;NoConcatenate&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;Load * Resident sales_data_sample&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;where FileNumber = $(vMin);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;store temp into [lib://Downloads/temp_$(i).qvd](qvd);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;drop table temp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Next i;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Drop table sales_data_sample;&lt;/DIV&gt;</description>
    <pubDate>Thu, 12 Jun 2025 14:28:57 GMT</pubDate>
    <dc:creator>rafaelencinas</dc:creator>
    <dc:date>2025-06-12T14:28:57Z</dc:date>
    <item>
      <title>Storing data into multiple files based on the line items in an account</title>
      <link>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2520969#M106484</link>
      <description>&lt;P&gt;Hi all!!!&lt;/P&gt;&lt;P&gt;I am working on a table output which we store into a CSV file. Here we have a field Account Numbers in which each account number will be repeated multiple times. If the line items for one account number is greated than 400,000 then we have to store them in a single CSV file with that account number included in the file name. The rest of the account numbers should come in a single dump.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 06:00:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2520969#M106484</guid>
      <dc:creator>qliksenseadminthomascook</dc:creator>
      <dc:date>2025-06-12T06:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data into multiple files based on the line items in an account</title>
      <link>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2521042#M106492</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Where are you trying to do this, In a Qlik sense app script?&lt;/P&gt;&lt;P&gt;it wouldn't be the best place to do this, but it would be possible.&lt;/P&gt;&lt;P&gt;Firstly create a table of the Account Number and record count.&amp;nbsp;&lt;/P&gt;&lt;P&gt;then you would need to create a loop that loops through where count &amp;gt;&amp;nbsp;&lt;SPAN&gt;400,000, using the peek function to populate a variable for the where and file name argument.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then you would need a second loop that created a table of all other account numbers then outputs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Mark&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 13:53:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2521042#M106492</guid>
      <dc:creator>Mark_Little</dc:creator>
      <dc:date>2025-06-12T13:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data into multiple files based on the line items in an account</title>
      <link>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2521044#M106493</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/293209"&gt;@qliksenseadminthomascook&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 - Load your data&lt;/P&gt;&lt;P&gt;2 - Create a column ID with RecNo()&amp;nbsp; ( it will be filled with the number of the row )&amp;nbsp;&lt;/P&gt;&lt;P&gt;3 - Create a new column FileNumber&amp;nbsp; - &amp;gt; ID / 400.000 (it will generate a new column with divisor number)&amp;nbsp;&lt;/P&gt;&lt;P&gt;4 - Peek the minimum and maximum value of&amp;nbsp; FileNumber&lt;/P&gt;&lt;P&gt;5 - Create a for statement for i = Min to Max and store your files&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;[sales_data_sample]:&lt;/DIV&gt;&lt;DIV&gt;LOAD&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[ORDERNUMBER],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[QUANTITYORDERED],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[PRICEEACH],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[ORDERLINENUMBER],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[SALES],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RowNo() as ID,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Floor(RowNo()&amp;nbsp; / 1000) as FileNumber&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;FROM [lib://Downloads/sales_data_sample.csv]&lt;/DIV&gt;&lt;DIV&gt;(txt, codepage is 1252, embedded labels, delimiter is ',', msq);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Temp:&lt;/DIV&gt;&lt;DIV&gt;Load&amp;nbsp; Min(FileNumber) as MinFile&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;,Max(FileNumber) as MaxFile&lt;/DIV&gt;&lt;DIV&gt;Resident sales_data_sample;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Let vMin = Peek('MinFile',0,'Temp') ;&lt;/DIV&gt;&lt;DIV&gt;Let vMax = Peek('MaxFile',0,'Temp') ;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Drop table&amp;nbsp;Temp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;trace =================;&lt;/DIV&gt;&lt;DIV&gt;trace $(vMin) - $(vMax);&lt;/DIV&gt;&lt;DIV&gt;trace =================;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;for i = vMin to vMax&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; temp:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;NoConcatenate&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;Load * Resident sales_data_sample&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;where FileNumber = $(vMin);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;store temp into [lib://Downloads/temp_$(i).qvd](qvd);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;drop table temp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Next i;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Drop table sales_data_sample;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Jun 2025 14:28:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2521044#M106493</guid>
      <dc:creator>rafaelencinas</dc:creator>
      <dc:date>2025-06-12T14:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data into multiple files based on the line items in an account</title>
      <link>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2521089#M106497</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/45380"&gt;@rafaelencinas&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;This works if I want all the csv files separately for each and every 1000 line items. However, I wanted is for the CSV to be created based on the account number. If the account number has 400,000 or more records that data should come to one file and all the other data should come to one file. Thank you for your help, I have achieved it with the below script:&lt;/P&gt;&lt;P&gt;MainTable:&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;IF(RecCount &amp;gt;= 400000, 'Large', 'Small') AS CountFlag;&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;Account,&lt;/P&gt;&lt;P&gt;COUNT(Account) AS RecCount&lt;/P&gt;&lt;P&gt;From qvd path;&lt;/P&gt;&lt;P&gt;Noconcatenate&lt;/P&gt;&lt;P&gt;SmallAccounts:&lt;/P&gt;&lt;P&gt;Load Account,&lt;/P&gt;&lt;P&gt;X,&lt;/P&gt;&lt;P&gt;Y,&lt;/P&gt;&lt;P&gt;Z&lt;/P&gt;&lt;P&gt;Resident&amp;nbsp;MainTable&lt;/P&gt;&lt;P&gt;where CountFlag = 'Small';&lt;/P&gt;&lt;P&gt;Store&amp;nbsp;SmallAccounts into [filepath/filename_SmallAccounts.csv](txt);&lt;/P&gt;&lt;P&gt;drop table SmallAccounts;&lt;/P&gt;&lt;P&gt;LargeAccountsList:&lt;BR /&gt;LOAD DISTINCT Account&lt;BR /&gt;RESIDENT MainTable&lt;BR /&gt;WHERE CountFlag = 'Large';&lt;/P&gt;&lt;P&gt;FOR i = 0 TO NoOfRows('LargeAccountsList') - 1&lt;/P&gt;&lt;P&gt;LET vAccountRaw = Peek('Account', $(i), 'LargeAccountsList');&lt;/P&gt;&lt;P&gt;LET vAccount = '$(vAccountRaw)';&lt;/P&gt;&lt;P&gt;// Load data for current account&lt;BR /&gt;LargeAccountData:&lt;/P&gt;&lt;P&gt;Load Account,&lt;/P&gt;&lt;P&gt;X,&lt;/P&gt;&lt;P&gt;Y,&lt;/P&gt;&lt;P&gt;Z&lt;/P&gt;&lt;P&gt;Resident&amp;nbsp;MainTable&lt;/P&gt;&lt;P&gt;WHERE Account = '$(vAccountRaw)';&lt;/P&gt;&lt;P&gt;// Check if any data exists before store&lt;BR /&gt;//IF NoOfRows('LargeAccountData') &amp;gt; 0 THEN&lt;/P&gt;&lt;P&gt;STORE LargeAccountData INTO [filepath/filename_$(vAccount).csv](txt);&lt;/P&gt;&lt;P&gt;DROP TABLE LargeAccountData;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NEXT&lt;/P&gt;&lt;P&gt;DROP TABLE LargeAccountsList;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 06:02:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Storing-data-into-multiple-files-based-on-the-line-items-in-an/m-p/2521089#M106497</guid>
      <dc:creator>qliksenseadminthomascook</dc:creator>
      <dc:date>2025-06-13T06:02:18Z</dc:date>
    </item>
  </channel>
</rss>

