<?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 Only Load if 1 file in location in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1723498#M592205</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a load where we receive 1 file a day. this must be loaded and saved before the following days file is then loaded.&lt;BR /&gt;This is to capture data where invoice lines are removed from the data......&lt;/P&gt;&lt;P&gt;Anyway, in short the automation that creates my source data from a local erp export occasionally fails to connect to the ftp location and then the next day there will be 2 files which load and breaks my file by file logic in the load.&lt;/P&gt;&lt;P&gt;QUESTION:&lt;/P&gt;&lt;P&gt;I load the data as *.xlsx as the data file has a timestamp, but i want to only load data when there is one file in the location, if there is 2 or more files in the location i would like the load to fail so i can then load manually in sequence.&lt;/P&gt;&lt;P&gt;Is there a way to script so that the load only runs when there is one file for import?&lt;/P&gt;&lt;P&gt;I have searched and not been able to find anything related. your expertise on this would be much appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 00:24:08 GMT</pubDate>
    <dc:creator>davyqliks</dc:creator>
    <dc:date>2024-11-16T00:24:08Z</dc:date>
    <item>
      <title>Only Load if 1 file in location</title>
      <link>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1723498#M592205</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a load where we receive 1 file a day. this must be loaded and saved before the following days file is then loaded.&lt;BR /&gt;This is to capture data where invoice lines are removed from the data......&lt;/P&gt;&lt;P&gt;Anyway, in short the automation that creates my source data from a local erp export occasionally fails to connect to the ftp location and then the next day there will be 2 files which load and breaks my file by file logic in the load.&lt;/P&gt;&lt;P&gt;QUESTION:&lt;/P&gt;&lt;P&gt;I load the data as *.xlsx as the data file has a timestamp, but i want to only load data when there is one file in the location, if there is 2 or more files in the location i would like the load to fail so i can then load manually in sequence.&lt;/P&gt;&lt;P&gt;Is there a way to script so that the load only runs when there is one file for import?&lt;/P&gt;&lt;P&gt;I have searched and not been able to find anything related. your expertise on this would be much appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 00:24:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1723498#M592205</guid>
      <dc:creator>davyqliks</dc:creator>
      <dc:date>2024-11-16T00:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Only Load if 1 file in location</title>
      <link>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1723618#M592206</link>
      <description>&lt;P&gt;Hi, there are many possibilities, I think one simple way to do it is adding a Filename() field, this will store the filename.&lt;/P&gt;&lt;P&gt;After the process you can load a table with the different filenames and if ther is more than one cancel the load&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// Read table adding filename field
LOAD
   ...
   FileNAme() as FileName
...;

// Check different FileNames loaded
tmpFilesLoaded:
LOAD Count(Distinct Filename) as FileNames
Resident TableName;

// If there is more than one different file anme throw an erro to cancel load
LET vFileNames = Peek('FileNames',0,'tmpFilesLoaded')
IF $(vFileNames)&amp;gt;1 THEN
  ThrowError
ENDIF

// Drop auxiliary table and field
DROP Table tmpFilesLoaded;
DROP Field Filename;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You can also create a bucle that reads all files, check example 2 of this help page that shows how to do that bucle:&amp;nbsp;&lt;A href="https://help.qlik.com/es-ES/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptControlStatements/For%20Each.htm" target="_blank"&gt;https://help.qlik.com/es-ES/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptControlStatements/For%20Each.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 15:59:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1723618#M592206</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2020-06-30T15:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Only Load if 1 file in location</title>
      <link>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1723850#M592207</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Thanks for this, i will try it today and feedback asap.&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 08:43:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1723850#M592207</guid>
      <dc:creator>davyqliks</dc:creator>
      <dc:date>2020-07-01T08:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Only Load if 1 file in location</title>
      <link>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1724166#M592208</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks again for the reply.&lt;/P&gt;&lt;P&gt;I found i had to change the capitalisation for Filename to FileName and add ; after the let statement and end if&lt;/P&gt;&lt;P&gt;But i cannot get the coding right for the Throw Error Part.&lt;/P&gt;&lt;P&gt;i tried with 'Then Exit script' but when loading 2 files the Filenames returned 2 in the document.&lt;/P&gt;&lt;P&gt;Here is the script i ended with, with no errors on load:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sales:&lt;BR /&gt;LOAD&lt;BR /&gt;*,&lt;BR /&gt;FileName() as FileName&lt;/P&gt;&lt;P&gt;FROM&lt;BR /&gt;[**********************************************LUK*.xlsx]&lt;BR /&gt;(ooxml, embedded labels);&lt;/P&gt;&lt;P&gt;tmpFilesLoaded:&lt;BR /&gt;LOAD Count(Distinct Filename) as FileNames&lt;BR /&gt;Resident Sales;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LET vFileNames = Peek('FileNames',0,'tmpFilesLoaded');&lt;BR /&gt;IF $(vFileNames)&amp;gt;1 THEN; EXIT SCRIPT&lt;/P&gt;&lt;P&gt;ENDIF;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DROP Table tmpFilesLoaded;&lt;BR /&gt;DROP Field FileName;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please can you show how you wrote the The throw error section?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you so much for your advise on this.&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 15:36:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1724166#M592208</guid>
      <dc:creator>davyqliks</dc:creator>
      <dc:date>2020-07-01T15:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Only Load if 1 file in location</title>
      <link>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1724299#M592209</link>
      <description>&lt;P&gt;Hi, if you use Exit script the app will load all data until it found the exit script clause, if you literally write 'throw error' (without quotes) or any other non-existant sentence like 'jmaisacsmf' it will return an error and not load anything.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 06:06:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1724299#M592209</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2020-07-02T06:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Only Load if 1 file in location</title>
      <link>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1724564#M592210</link>
      <description>&lt;P&gt;Thanks for this,&lt;/P&gt;&lt;P&gt;the error in syntax confused me but i see when one file loaded the load is fine and when a second file loaded the Error stops the script, thanks alot.&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 15:27:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1724564#M592210</guid>
      <dc:creator>davyqliks</dc:creator>
      <dc:date>2020-07-02T15:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Only Load if 1 file in location</title>
      <link>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1728045#M592211</link>
      <description>&lt;P&gt;Just throwing this one out there too, there is a fairly new 'File Exists' trigger for Publisher too, which you may not have known, this may be easier.&amp;nbsp; The trick is to be sure once the task triggers due to the file being there, you run a secondary task to delete the file, so it does not keep triggering the task...&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/qlikview/April2020/Subsystems/QMC/Content/QV_QMC/QMC_System_SupportingTasks_ExternalPrograms_General.htm" target="_blank"&gt;https://help.qlik.com/en-US/qlikview/April2020/Subsystems/QMC/Content/QV_QMC/QMC_System_SupportingTasks_ExternalPrograms_General.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 13:27:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Only-Load-if-1-file-in-location/m-p/1728045#M592211</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2020-07-15T13:27:03Z</dc:date>
    </item>
  </channel>
</rss>

