Managing file locations and connection strings - Qlik View

In our current example documents, we have always referred to the Data Files folder for our source data. If, for any reason, this folder has to be moved somewhere else, we will have to manually change the source data path in many locations in many files.

Let's follow these steps to create an included script file to set the source data folder in a single location:

  1. Open Notepad (by pressing Windows Key + R, typing in notepad, and pressing Return) or any other text editor.
  2. Enter the following script:
    SET vFolderSourceData = '..Data Files';
  3. Save the file to the same folder as your QlikView document and call
    it Config.qvs.
  4. Close Notepad and return to QlikView'sscript editor window.
  5. Go to the Include tab and place the cursor on the first line.
  6. Go to Insert | Include Statement and select the Config.qvs file.

We have now created an include file that sets the vFolderSourceData variable to the path of the source data folder.

In a real QlikView environment, it is advisable to specify paths in UNC format, for example: myserversource_data.

Now all we have to do is replace every instance of the hardcoded file path with the new variable file path. To do this, follow these steps:

  1. In the Edit Script window, select Edit | Find/Replace from the menu.
  2. In the Find What input box enter ..Data Files.
  3. In the Replace With input box enter $(vFolderSourceData).
  4. Check the Search all tabs checkbox.
  5. Click on the Replace All button.
  6. Click on the Close button to close the dialog window.

Managing-file-locations-and-Connection-String

Every hardcoded instance of the source data folder is now changed to the vFolder Source Data variable. Now, if we need to change the folder location we only need to change it in a single place. Of course, the same logic can be applied for database connection strings.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Qlik View Topics