<?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: Deleting bogus fields from a table in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Deleting-bogus-fields-from-a-table/m-p/981186#M334949</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Hi DataNibbler,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Reverse the order you go through the fields and your code will work&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;//For i=&amp;nbsp; 1&amp;nbsp; to NoOfFields('Extradaten')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For i= NoOfFields('Extradaten') to 1 step -1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you delete a field you change the index of field that follow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;NoOfFields('Extradaten') changes as you drop fields. Try this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Set vNumLoops = &lt;SPAN style="font-size: 13.3333px;"&gt;NoOfFields('Extradaten')&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Then run your code with &lt;SPAN style="font-size: 13.3333px;"&gt;For i=&amp;nbsp; 1&amp;nbsp; to $(&lt;SPAN style="font-size: 13.3333px;"&gt;vNumLoops&lt;/SPAN&gt;) and you'll get an error as the script will look for a sixth field that will no longer exist.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Cheers&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Nov 2015 22:10:10 GMT</pubDate>
    <dc:creator>effinty2112</dc:creator>
    <dc:date>2015-11-25T22:10:10Z</dc:date>
    <item>
      <title>Deleting bogus fields from a table</title>
      <link>https://community.qlik.com/t5/QlikView/Deleting-bogus-fields-from-a-table/m-p/981185#M334948</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;I have a table that is created in quite a complicated manner. But that is not the issue, I have the table already.&lt;/P&gt;&lt;P&gt;Now there are two types of fields in this table:&lt;/P&gt;&lt;P&gt;- For every month (so far) in the current year, there is a field with the total of operating_hrs.&lt;/P&gt;&lt;P&gt;- After every such field, there is a field subtracting the previous month's total from this month's total and thus calculating how many&lt;BR /&gt;&amp;nbsp; operating_hrs were added in the course of that month.&lt;/P&gt;&lt;P&gt;I attach a small sample - there are only a few months there and only one record, but I think it's enough to get the picture:&lt;/P&gt;&lt;P&gt;- We have no data yet for Nov and Dec, so these fields are labeled 'dummy' with a number (dummy_44 and dummy_45 in this instance).&lt;/P&gt;&lt;P&gt;- For that reason, QlikView cannot draw the difference. The operating_hrs in Nov ("BS_Nov") are present as a field, it's hardcoded,&lt;/P&gt;&lt;P&gt;&amp;nbsp; but the value in the first line (as in every line) is 'NN'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to delete both these kinds of fields. I also attach the code I am currently using to do that.&lt;/P&gt;&lt;P&gt;Strangely, when i use only the first IF_clause in the LOOP, the fields 'dummy_44' and 'dummy_45' are both deleted as they should be.&lt;/P&gt;&lt;P&gt;&amp;lt;=&amp;gt; When I use both IF_clauses in the LOOP, the fields with the value 'NN' are all deleted as is 'dummy_44' - but 'dummy_45' remains.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody spot why that would be so?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 15:04:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Deleting-bogus-fields-from-a-table/m-p/981185#M334948</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2015-11-25T15:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting bogus fields from a table</title>
      <link>https://community.qlik.com/t5/QlikView/Deleting-bogus-fields-from-a-table/m-p/981186#M334949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Hi DataNibbler,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Reverse the order you go through the fields and your code will work&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;//For i=&amp;nbsp; 1&amp;nbsp; to NoOfFields('Extradaten')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For i= NoOfFields('Extradaten') to 1 step -1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you delete a field you change the index of field that follow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;NoOfFields('Extradaten') changes as you drop fields. Try this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Set vNumLoops = &lt;SPAN style="font-size: 13.3333px;"&gt;NoOfFields('Extradaten')&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Then run your code with &lt;SPAN style="font-size: 13.3333px;"&gt;For i=&amp;nbsp; 1&amp;nbsp; to $(&lt;SPAN style="font-size: 13.3333px;"&gt;vNumLoops&lt;/SPAN&gt;) and you'll get an error as the script will look for a sixth field that will no longer exist.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Cheers&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 22:10:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Deleting-bogus-fields-from-a-table/m-p/981186#M334949</guid>
      <dc:creator>effinty2112</dc:creator>
      <dc:date>2015-11-25T22:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting bogus fields from a table</title>
      <link>https://community.qlik.com/t5/QlikView/Deleting-bogus-fields-from-a-table/m-p/981187#M334950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi DataNibbler,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever the loop drops a field, the field position (Order) has been changed in the table. So, we need to go one step &lt;SPAN style="font-size: 13.3333px;"&gt;back and check the replaced column name&lt;/SPAN&gt;. So, I reset the i value by using &lt;STRONG&gt;i=i-1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1448504953451526 jive_text_macro" jivemacro_uid="_1448504953451526" modifiedtitle="true"&gt;
&lt;P&gt;FOR i=1 TO NoOfFields('Extradaten')&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; v_field = FieldName($(i), 'Extradaten')&lt;/P&gt;
&lt;P&gt;&amp;nbsp; IF Left('$(v_field)', 5) = 'dummy' OR Fieldvalue('$(v_field)', 1) = 'NN' THEN&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DROP FIELD '$(v_field)' FROM Extradaten;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i= i-1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; END IF&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;NEXT i&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Check the attachment and Let me know.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Nov 2015 02:36:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Deleting-bogus-fields-from-a-table/m-p/981187#M334950</guid>
      <dc:creator>tamilarasu</dc:creator>
      <dc:date>2015-11-26T02:36:08Z</dc:date>
    </item>
  </channel>
</rss>

