<?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: Creating Custom Function To Write Contents Of Table Field To Variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992084#M337991</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You didn't need this you could simply use exists() for this, see as an example: &lt;A href="https://community.qlik.com/docs/DOC-7020"&gt;The exists issue&lt;/A&gt;. And if you need to get (all) field-values you could use field-functions like fieldvalue() which meant you looped through the distinct values from the field directly and it's much faster then the table-loop per peek().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Sep 2015 12:33:58 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2015-09-08T12:33:58Z</dc:date>
    <item>
      <title>Creating Custom Function To Write Contents Of Table Field To Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992083#M337990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First post, so am sorry if i am posting this in the wrong place or or am missing something.&lt;/P&gt;&lt;P&gt;I am trying to write a function/expression so that i can input a table name and a field and it returns all of the field elements separated by commas. I couldn't find an easier way to do this so custom code it is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what i have so far&lt;/P&gt;&lt;P&gt;SET tableFieldToString =&lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vReturn_TFTS = ''chr(59)&lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vNumRows = NoOfRows($1)chr(59)&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF $(vNumRows) &amp;gt; 0 THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp; FOR i = 1 to $(vNumRows)&lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vReturn_TFTS = '$(vReturn_TFTS)' &amp;amp; Peek($2,$(i),$1)chr(59)&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF i &amp;lt; $(vNumRows) THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vReturn_TFTS = '$(vReturn_TFTS)' &amp;amp; ','chr(59)&lt;/P&gt;&lt;P&gt;&amp;nbsp; ENDIF&lt;/P&gt;&lt;P&gt;&amp;nbsp; NEXT&lt;/P&gt;&lt;P&gt;&amp;nbsp; ELSE&lt;/P&gt;&lt;P&gt;&amp;nbsp; $(vReturn_TFTS)chr(59)&lt;/P&gt;&lt;P&gt;&amp;nbsp; ENDIF&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;The idea would be to call the above function in the following way&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;$(tableFieldToString('tableName','fieldName'));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To explain the logic.&lt;/P&gt;&lt;P&gt;- set the return variable to blank&lt;/P&gt;&lt;P&gt;- count the number of rows in the table&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;- if the number of rows in the table is greater than zero then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Iterate through each row of the table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Peek at the field given the row number and table then amend it to the return variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Make sure to add a comma between records&lt;/P&gt;&lt;P&gt;- Else return a blank variable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Ultimately i am trying to use the comma separated list in a match statement during a load so i can exclude values in one table from another. The data/script would look something like this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RemoveTheseValues:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;_Key&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NewTableWithRemovedValues:&lt;/P&gt;&lt;P&gt;LOAD *&lt;/P&gt;&lt;P&gt;RESIDENT &lt;SPAN style="font-size: 13.3333px;"&gt;SomeTable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;WHERE NOT match(_Key,$(tableFieldToString('&lt;SPAN style="font-size: 13.3333px;"&gt;RemoveTheseValues&lt;/SPAN&gt;','&lt;SPAN style="font-size: 13.3333px;"&gt;_Key&lt;/SPAN&gt;')));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help or alternate suggestions would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Simeon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2015 04:26:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992083#M337990</guid>
      <dc:creator>simeonlukich</dc:creator>
      <dc:date>2015-09-08T04:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom Function To Write Contents Of Table Field To Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992084#M337991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You didn't need this you could simply use exists() for this, see as an example: &lt;A href="https://community.qlik.com/docs/DOC-7020"&gt;The exists issue&lt;/A&gt;. And if you need to get (all) field-values you could use field-functions like fieldvalue() which meant you looped through the distinct values from the field directly and it's much faster then the table-loop per peek().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2015 12:33:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992084#M337991</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-09-08T12:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom Function To Write Contents Of Table Field To Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992085#M337992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;As Marcus says, you can make use of the exists function to filter the records but if you ever want to construct a string of delimeted field values, you may use the following method also&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;xx:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD Concat(_Key,',') as _Key INLINE [&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_Key&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let vtableFieldToString=peek('_Key',0,'xx');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hth&lt;/P&gt;&lt;P&gt;Sasi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2015 14:07:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992085#M337992</guid>
      <dc:creator>sasiparupudi1</dc:creator>
      <dc:date>2015-09-08T14:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom Function To Write Contents Of Table Field To Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992086#M337993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your reply. I feel like an idiot as i have used exist in the past but didn't think to use it this time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2015 21:18:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992086#M337993</guid>
      <dc:creator>simeonlukich</dc:creator>
      <dc:date>2015-09-08T21:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom Function To Write Contents Of Table Field To Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992087#M337994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that, that is useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2015 21:18:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-Custom-Function-To-Write-Contents-Of-Table-Field-To/m-p/992087#M337994</guid>
      <dc:creator>simeonlukich</dc:creator>
      <dc:date>2015-09-08T21:18:36Z</dc:date>
    </item>
  </channel>
</rss>

