<?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: exists function issue to drop fields if that field exists in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232984#M84535</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;its working using the * (without quotes), although it is displayed as being syntactically incorrect in the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If field &lt;SPAN style="color: #3d3d3d; font-family: Helvetica;"&gt;'FS_ReprintServer'&lt;/SPAN&gt; exists in several tables though, it looks like the fieldnumber of the latest table loaded is being shown.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Sep 2016 08:19:56 GMT</pubDate>
    <dc:creator>hugmarcel</dc:creator>
    <dc:date>2016-09-15T08:19:56Z</dc:date>
    <item>
      <title>exists function issue to drop fields if that field exists</title>
      <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232979#M84530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a application table that contain a list of all customer tables that i loop through. Not all the tables contain the same fields, as a result i would like to drop certain fields.&lt;/P&gt;&lt;P&gt;The code works fine but i get the unwanted fields, i am able to drop some fields as those fields are within each table and are not necessary. The issue is with the "exists()" function, i would like to use that to check to see if a field exists, then drop it from the table.&lt;/P&gt;&lt;P&gt;if i cannot used the exists() function is there a better way to check if field exists, these unwanted fields are NULL.&lt;/P&gt;&lt;P&gt;code&lt;/P&gt;&lt;P&gt;//********************** Categories built for Customer ******************************************&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LET NumberOfTables = NoOfRows('FS_Categories');&lt;/P&gt;&lt;P&gt;FOR i = 0 to $(NumberOfTables)-1&lt;BR /&gt;&lt;BR /&gt; LET C= peek('CategoryName', $(i), 'FS_Categories');&lt;BR /&gt;&lt;BR /&gt; [$(C)]:&lt;BR /&gt; QUALIFY *;&lt;BR /&gt; UNQUALIFY DocID, SatID, DateDelete, DocType, OfflineDate, DeleteFlag, "FS_InboxOwner", "FS_InboxSubject", FS_ReprintServer, FS_ReprintPrinter ;&lt;BR /&gt;&lt;BR /&gt; LOAD *;&lt;BR /&gt; SQL Select *&lt;BR /&gt; FROM $(vDBName).[$(C)];&lt;BR /&gt;&lt;BR /&gt; UNQUALIFY *;&lt;BR /&gt;&lt;BR /&gt; DROP FIELDS SatID, DateDelete, DocType, OfflineDate, DeleteFlag, "FS_InboxOwner", "FS_InboxSubject" FROM [$(C)];&lt;BR /&gt;&lt;BR /&gt; STORE [$(C)] into $(vDataSourcePath)$(C).qvd; //store every table to qvd in datasources&lt;BR /&gt;&lt;BR /&gt; //if (exists('$(C)'.FS_ReprintServer)=-1) then&lt;BR /&gt; // DROP FIELD [$(C).FS_ReprintServer] FROM [$(C)];&lt;BR /&gt; //end if&lt;BR /&gt;&lt;BR /&gt; drop table [$(C)];&lt;BR /&gt;&lt;BR /&gt;NEXT&lt;/P&gt;&lt;P&gt;//***************************************************************&lt;/P&gt;&lt;P&gt;drop table FS_Categories;&lt;/P&gt;&lt;P&gt;\code&lt;/P&gt;&lt;P&gt;thankyou all in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2010 05:51:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232979#M84530</guid>
      <dc:creator />
      <dc:date>2010-02-06T05:51:28Z</dc:date>
    </item>
    <item>
      <title>exists function issue to drop fields if that field exists</title>
      <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232980#M84531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;I found a workaround using the exists&lt;/P&gt;&lt;P&gt;if(exists("FS_ReprintServer",'NULL')=0 then&lt;/P&gt;&lt;P&gt;drop field ....&lt;/P&gt;&lt;P&gt;end if&lt;/P&gt;&lt;P&gt;however, is there a better way to do this?&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2010 14:42:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232980#M84531</guid>
      <dc:creator />
      <dc:date>2010-02-06T14:42:37Z</dc:date>
    </item>
    <item>
      <title>exists function issue to drop fields if that field exists</title>
      <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232981#M84532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about using FieldNumber()? For example:&lt;/P&gt;&lt;P&gt;IF FieldNumber('FS_ReprintServer') &amp;gt; 0 THEN&lt;BR /&gt; DROP FIELD FS_ReprintServer;&lt;BR /&gt;END IF&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2010 22:34:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232981#M84532</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2010-02-06T22:34:06Z</dc:date>
    </item>
    <item>
      <title>exists function issue to drop fields if that field exists</title>
      <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232982#M84533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;thankyou for the help!&lt;/P&gt;&lt;P&gt;i just had to add the table name then move this before my store code line&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; IF FieldNumber('$(C).FS_ReprintServer','$(C)') &amp;gt; 0 THEN&lt;BR /&gt; DROP FIELD '$(C).FS_ReprintServer', '$(C).FS_ReprintPrinter' FROM [$(C)];&lt;BR /&gt; END IF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Feb 2010 05:30:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232982#M84533</guid>
      <dc:creator />
      <dc:date>2010-02-07T05:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: exists function issue to drop fields if that field exists</title>
      <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232983#M84534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to add to this that if you don't want to use a specific table, you should add the wildcard character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, the code which you would get is:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;IF FieldNumber('FS_ReprintServer',*) &amp;gt; 0 THEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;DROP FIELD FS_ReprintServer;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;END IF&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2016 07:46:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232983#M84534</guid>
      <dc:creator>stevenkoppens</dc:creator>
      <dc:date>2016-08-24T07:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: exists function issue to drop fields if that field exists</title>
      <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232984#M84535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;its working using the * (without quotes), although it is displayed as being syntactically incorrect in the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If field &lt;SPAN style="color: #3d3d3d; font-family: Helvetica;"&gt;'FS_ReprintServer'&lt;/SPAN&gt; exists in several tables though, it looks like the fieldnumber of the latest table loaded is being shown.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2016 08:19:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232984#M84535</guid>
      <dc:creator>hugmarcel</dc:creator>
      <dc:date>2016-09-15T08:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: exists function issue to drop fields if that field exists</title>
      <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232985#M84536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Addition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"IF FieldNumber('FS_ReprintServer',*) &amp;gt; 0 THEN ..." does not work if you use it in a sub.&lt;/P&gt;&lt;P&gt;The script will terminate with an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I propose to use FIELDVALUECOUNT() instead to determine if a field exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g. you can use&lt;/P&gt;&lt;P&gt;//Check if field QVField exists (in any table)&lt;BR /&gt;SUB CheckFieldExists ( QVField )&lt;BR /&gt;&amp;nbsp; LET gFieldExists = 0;&lt;BR /&gt;&amp;nbsp; IF (NOT ISNULL(FIELDVALUECOUNT('$(QVField)'))) THEN&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET gFieldExists = 1;&lt;BR /&gt;&amp;nbsp; END IF&lt;BR /&gt;END SUB&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELDVALUECOUNT returns 0 if QVField contains NULL() values only, and NULL if it does not exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2016 08:58:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232985#M84536</guid>
      <dc:creator>hugmarcel</dc:creator>
      <dc:date>2016-09-15T08:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: exists function issue to drop fields if that field exists</title>
      <link>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232986#M84537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Marcel,&amp;nbsp; I extended your code and created this sub to drop a field&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// This Sub will check if a field exists before dropping it&lt;BR /&gt;// Use to avoid errors during script load when dropping fields due to name changes;&lt;BR /&gt;// Example:&lt;BR /&gt;// if call QVSDeveloper.DropFieldExist('MyColumnName')&lt;/P&gt;&lt;P&gt;SUB QVSDeveloper.DropFieldExist (vL._Root)&lt;BR /&gt; IF (NOT ISNULL(FIELDVALUECOUNT('$(vL._Root)'))) THEN&lt;BR /&gt;&amp;nbsp; DROP FIELD '$(vL._Root)';&lt;BR /&gt; ELSE&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; TRACE '$(vL._Root) Field Not Found';&lt;BR /&gt; ENDIF&lt;BR /&gt; SET vL._Root=;&lt;BR /&gt;END SUB;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Apr 2017 15:06:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/exists-function-issue-to-drop-fields-if-that-field-exists/m-p/232986#M84537</guid>
      <dc:creator>aritting</dc:creator>
      <dc:date>2017-04-19T15:06:25Z</dc:date>
    </item>
  </channel>
</rss>

