Well-commented variables. Be careful!

         Generally in any programming language comments are a good stuff. Comments help us quicker understand what’s going on in this particular part of code. Well-commented code is always sign of good and qualitative work. QlikView is not an exception, but here you can become a victim of your diligence, especially when you dealing with variables. Stop talk – let’s check.

     

    Let’s have a look on my variables:

    vSales1

    1.png

    vSales2

    2.png

    Put them together in the chart. Of course in my case there is no any kind of sense, but we are testing “other side”.

     

    Let’s create three almost exact expressions:

    Expression1:

    3.png
    Expression2:

    4.png

    Expression3:

    5.png

    And we expect that result will be the same in all of three columns, but surprisingly it’s not.

    6.png

     

    Magic? Definitely it’s not!

    The deal is in variables’ nature. It’s well described by HIC in his post The Magic of Variables

     

    Remember that variable in QlikView without equal sign is just a text! This text completely inserted instead of variable including comments. So in reality we got expressions like below:

    Expression1:

    7.png

    Expression2:

    8.png

    Expression3:

    9.png

    Now result become quite understandable.

     

     

    This post is not an appeal of omitting comments in your variables’ code, just a kind of warning to be careful.

    Because to find this “bug“ you can spend hours and hours especially when you’ve been working with your application for several days and everything seems to be the same.

     

    Have a nice day.

     

    Regards,

    Andrei