In the past, I have blogged about the FileName function and how I used it to generate data for my Qlik Sense app. Today, I thought I would blog about another file function, the FileSize function. The FileSize function is a script function that can be used to return the size of a file or table. The FileSize function returns an integer for the size, in bytes, of the file specified or a table. The file can be a QVD, a text file, an Excel file or a table. The syntax is quite simple:
Syntax:
FileSize([filename])
I have used the FileSize function to determine if a QVD exists before I load it. In the example script below, I set the size of the CustomerMaster QVD to the vSize variable. Then I check the variable to see if a size was returned. If a size was returned meaning a QVD is there, I load the QVD. If the QVD does not exist then the FileSize function will return null.
The FileSize function can also be used to return the table size of the table file being read. To do this, the FileSize function is used in the Load statement as seen in the example script below. When the filename parameter is excluded, then the FileSize function will return the size of the table currently being read. The TableSize field will store the size of the CustomerMaster table after it has been loaded.
The FileSize function is another easy-to-use script file function that can be used in Qlik Sense or QlikView to provide the size of a file or a table. Use the FileSize function as a checkpoint in your script to ensure the file is available before loading, as I did in the example above, or use it ensure size requirements for files being loaded are being met in your app. Good luck scripting!
Thanks,
Jennell