<?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 several rows for each row (with a new column) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2030090#M1222352</link>
    <description>&lt;P&gt;You can use the following approach to generate column C in your table:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a new table using the Resident load statement. This table will have the same number of rows as your original table, but with an additional column C.&lt;/LI&gt;
&lt;LI&gt;In the Resident load statement, use a while loop and the rowno() function to iterate through the rows of your original table.&lt;/LI&gt;
&lt;LI&gt;In the while loop, use a condition that compares the current row number to the max value of column B.&lt;/LI&gt;
&lt;LI&gt;Inside the while loop, use the date from column A and the rowno() function to calculate the value for column C.&lt;/LI&gt;
&lt;LI&gt;Use the Concatenate function to combine columns A, B, and C in the new table&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Here is an example of how the script would look:&lt;/P&gt;
&lt;P&gt;// Create new table with column C Temp: Load date as A, rowno() as B, While(rowno() &amp;lt;= max(B), if(rowno()=1,date,date(date+rowno()-1)) as C, resident [Original Table] );&lt;/P&gt;
&lt;P&gt;//Concatenate all columns Concatenate(Temp) Load * Resident Temp;&lt;/P&gt;
&lt;P&gt;This script creates a new table called "Temp" that has the same number of rows as the original table, but with the additional column C. The while loop iterates through the rows of the original table, using the rowno() function to compare the current row number to the max value of column B. The loop terminates once the current row number exceeds the max value of column B. The value for column C is calculated using the date from column A and the rowno() function inside the loop. Finally, it concatenates all the columns of the new table with the original table.&lt;/P&gt;
&lt;P&gt;Please keep in mind that this script is a sample and that it may need to be adapted to your specific use case and data structure.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jan 2023 20:51:25 GMT</pubDate>
    <dc:creator>jcmachado</dc:creator>
    <dc:date>2023-01-25T20:51:25Z</dc:date>
    <item>
      <title>Generate several rows for each row (with a new column)</title>
      <link>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2029963#M1222345</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I want to generate the column C from a table witch has dates (like in column A) and a correspind number (rowno() ) in column B. I have of course only 6 rows in my table right now (from 01/01 to 06/01).&lt;BR /&gt;I don't see how to do that, probably by creating a new table and using Resident, but how can I use a "while" where condition depends of reaching the max value of B ? (or you see an other way ?)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="temp.png" style="width: 354px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/98849iDEA032094225C258/image-size/large?v=v2&amp;amp;px=999" role="button" title="temp.png" alt="temp.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 15:39:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2029963#M1222345</guid>
      <dc:creator>ok5454564</dc:creator>
      <dc:date>2023-01-25T15:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Generate several rows for each row (with a new column)</title>
      <link>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2030090#M1222352</link>
      <description>&lt;P&gt;You can use the following approach to generate column C in your table:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a new table using the Resident load statement. This table will have the same number of rows as your original table, but with an additional column C.&lt;/LI&gt;
&lt;LI&gt;In the Resident load statement, use a while loop and the rowno() function to iterate through the rows of your original table.&lt;/LI&gt;
&lt;LI&gt;In the while loop, use a condition that compares the current row number to the max value of column B.&lt;/LI&gt;
&lt;LI&gt;Inside the while loop, use the date from column A and the rowno() function to calculate the value for column C.&lt;/LI&gt;
&lt;LI&gt;Use the Concatenate function to combine columns A, B, and C in the new table&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Here is an example of how the script would look:&lt;/P&gt;
&lt;P&gt;// Create new table with column C Temp: Load date as A, rowno() as B, While(rowno() &amp;lt;= max(B), if(rowno()=1,date,date(date+rowno()-1)) as C, resident [Original Table] );&lt;/P&gt;
&lt;P&gt;//Concatenate all columns Concatenate(Temp) Load * Resident Temp;&lt;/P&gt;
&lt;P&gt;This script creates a new table called "Temp" that has the same number of rows as the original table, but with the additional column C. The while loop iterates through the rows of the original table, using the rowno() function to compare the current row number to the max value of column B. The loop terminates once the current row number exceeds the max value of column B. The value for column C is calculated using the date from column A and the rowno() function inside the loop. Finally, it concatenates all the columns of the new table with the original table.&lt;/P&gt;
&lt;P&gt;Please keep in mind that this script is a sample and that it may need to be adapted to your specific use case and data structure.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 20:51:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2030090#M1222352</guid>
      <dc:creator>jcmachado</dc:creator>
      <dc:date>2023-01-25T20:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Generate several rows for each row (with a new column)</title>
      <link>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2030336#M1222371</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proof.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/98918i09398686C404FB6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="proof.png" alt="proof.png" /&gt;&lt;/span&gt;Thanks for your answer.&lt;/P&gt;
&lt;P&gt;Your solution doesnt seem to be correct when i copy it and change value by mine, can you make a quick example ?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 12:20:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2030336#M1222371</guid>
      <dc:creator>ok5454564</dc:creator>
      <dc:date>2023-01-26T12:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: Generate several rows for each row (with a new column)</title>
      <link>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2030573#M1222382</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a combination of the resident load and a while loop to generate the column C based on the values in columns A and B.&lt;/P&gt;
&lt;P&gt;Here's an example of how you can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Create a new table with the original data&lt;/P&gt;
&lt;P&gt;Resident YourTable;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Create a variable to store the current row number&lt;/P&gt;
&lt;P&gt;let vCurrentRow = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Create a variable to store the maximum row number&lt;/P&gt;
&lt;P&gt;let vMaxRow = max(B);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Create a variable to store the current date&lt;/P&gt;
&lt;P&gt;let vCurrentDate = peek(A, vCurrentRow);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Use a while loop to iterate through the rows&lt;/P&gt;
&lt;P&gt;while(vCurrentRow &amp;lt;= vMaxRow)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; // Create a new column C with the current date&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; YourTable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; load&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A as C&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; resident YourTable&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; where B = $(vCurrentRow);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; // Increment the current row number&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; let vCurrentRow = vCurrentRow + 1;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;DIV class="bg-black mb-4 rounded-md"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;In this example, the resident load is used to create a new table with the original data. Then, a while loop is used to iterate through the rows of the table based on the values in column B. Inside the while loop, a new column C is created with the current date from column A. The where condition is used to filter the rows based on the current row number stored in the vCurrentRow variable. Finally, the vCurrentRow variable is incremented at the end of each iteration so that the next row is processed on the next iteration.&lt;/P&gt;
&lt;P&gt;Note that, this is a basic example, you may need to adjust the script to match your specific requirements and also you might need to handle the case where you have duplicate values in column B. Please let me know if you have any other question.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 21:01:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Generate-several-rows-for-each-row-with-a-new-column/m-p/2030573#M1222382</guid>
      <dc:creator>jcmachado</dc:creator>
      <dc:date>2023-01-26T21:01:10Z</dc:date>
    </item>
  </channel>
</rss>

