Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create a table based on comma seperated values

<body><p>Hello everyone</p> <p>I want to write a generic script which can be better explained as follows:</p> <p> <table width="333" cellpadding="0" cellspacing="0" border="0" style="width: 250pt; border-collapse: collapse;"> <colgroup><strong><col width="64" style="width: 48pt;"></col><col width="269" style="width: 202pt; mso-width-source: userset; mso-width-alt: 9837;"></col></strong></colgroup> <tbody> <tr height="17" style="height: 12.75pt;"> <td width="64" height="17" style="background-color: transparent; width: 48pt; height: 12.75pt; border: #ece9d8;"><strong>USER</strong></span></td> <td width="269" class="xl63" style="background-color: transparent; width: 202pt; border: #ece9d8;"><strong>Values</strong></span></td> </tr> <tr height="17" style="height: 12.75pt;"> <td height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"></span></td> <td class="xl63" style="background-color: transparent; border: #ece9d8;"></span></td> </tr> <tr height="17" style="height: 12.75pt;"> <td height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;">One</span></td> <td class="xl63" style="background-color: transparent; border: #ece9d8;">4500, 6700</span></td> </tr> <tr height="17" style="height: 12.75pt;"> <td height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;">Two</span></td> <td x:num="2.1" class="xl63" style="background-color: transparent; border: #ece9d8;">2,1</span></td> </tr> <tr height="17" style="height: 12.75pt;"> <td height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;">Three</span></td> <td class="xl63" style="background-color: transparent; border: #ece9d8;">23, 2420, 6451</span></td> </tr> </tbody> </table> </p> <p>For each user, I would like to create a table with a separate row for each value found ie</p> <p><pre class="jive_text_macro jive_macro_code" jivemacro="code" ___default_attr="plain"></p> <p>One, 4500</p> <p>One, 6700</p> <p>Two, 2</p> <p>Two, 1</p> <p>Three, 23</p> <p>Three,2420</p> <p>Three, 6451<!--StartFragment--></p> <p></pre></p> <p>I kinda know that one has to create a FOR EACH loop or a WHILE loop and create a new table but the syntax of it escapes me. </p> <p>How do I create a script in QV that reads in this table and for each user, seperate the values found in the Values field and create a new row?</p> <p>All help much appreciated!</p></body>

1 Reply
hector
Specialist
Specialist

HI, you don't have to use a for/each statement

with this script i did what you want


LOAD
USER,
subfield(Values,',') as Value
INLINE [
USER;Values
One; 4500, 6700
Two; 2,1
Three; 23, 2420, 6451
](delimiter is ';');


i've changed the delimiter, just to adjust he format

rgds