Friday, August 30, 2013

Qlikview Project Files Can Help You Manipulate Objects

I was working on a QlikView for a customer the other day and I was frustrated because I could not re-size the right column of a Current Selections box. I kept getting that annoying scroll bar that makes the object look kind of ugly.

Like This...
The solution to this problem is to re-size the columns, well the left column is already pretty small and if you are on QV 11 SR3 you will notice that you cannot grab the re-size handle for the right hand column. So I pulled my hair out for a few minutes and then had a revelation. If I create a project file for the application then I could manipulate the properties in the xml definition of the object.

  • First create a folder in the same directory as your application with the same name as the application with "-prj" added to the end. Just like this.



  • Next open your QlikView application and click save. Qlikview will automatically export the definition of your application to the -prj folder. Open the properties of the object you want to manipulate and find the object ID on the general tab. Then close QlikView. 
  • Open the project folder and find the xml file for the object you want to change. In my case it is the CS01.xml for the Current Selections object.

  • Open the xml file in a text editor and start searching for things you can mess with I wanted to manipulate the column widths so I found some properties that looked promising. I changed some of the numbers to see what would happen. The sequence of what you do here is very important. Make sure your QVW file is closed, make your change to the XML and save the XML. When you open the qvw Qlikview will read the definition of the objects from the xml and update the object definition to reflect what has changed in the xml. If you are not happy with the change then close the qvw and tweak the setting again, save the xml and reopen the qvw. 

  • I reduced the third ColWidths property to 40 and poof no more scroll bar.


This Project folder feature is part of the change management integration but it exposes limitless properties. I have to explore how it would be done but I think this approach would give you great time savings if  you are faced with making mass updates to colors, styles and fonts. Try some experimentation and see what you can do.


Monday, August 26, 2013

QlikView "Execute" can save your butt!

I ran into an issue the other day. I wanted to pull some data from a site and the data was stored in multiple xml files within a zip file.

This presented two problems for me as a QlikView Developer. How do I get the zip file down to my computer? Then how do I unzip the files so QlikView can read them?

Qlikview's "Execute" command makes this all possible.
You do have to enable execution of external programs in your load script but otherwise it is just another line of code.


The zip file was found at http://somedomain/somezip.zip so in order to download it I had to use a powershell command luckily the windows command line will execute powershell commands.

Disclaimer: I DON'T KNOW ANYTHING about powershell so be advised, comments on this post asking how to do stuff in powershell will be met with crickets. I'm sure there is great stuff in there and I'll figure those things out when I need them. I did some googling to figure out how to download the file from the command line so this line of code is all I know about powershell.

execute cmd.exe /C powershell (New-Object System.Net.WebClient).DownloadFile('http://somedomain.com/somezip.zip','C:\Test\somezip.zip');

So that line of code downloads the zip file from the web site and stages it in c:\Test. The next challenge is unzipping it. You may be able to extract the contents of a zip file from windows explorer but there is way to do it from the command line without downloading an executable that you can call. I got mine from http://stahlworks.com/dev/?tool=zipunzip download at your own risk. Once I downloaded the file I placed it in C:\Windows\System32. From there I could call it from my Qlikview load script using the Execute command.


execute cmd.exe /C unzip -o C:\Test\somezip.zip -d C:\Test;

This was just one way I am using the Execute command but there are many ways you can use it. For example you may want to copy data files to another directory after you load them. There are almost unlimited things you can do from the command line so keep it in mind when you are trying to solve a tricky problem.