A little tool for creating nested if-statements

Nested If-statements are sometimes necessary in QlikView- load-scripts, unfortunately.
They are quite difficult to read and very tricky to create and especially to debug.

In the last recent months I had a lot of projects where a tenfold nesting of if-statements was not uncommon.

After struggling with these nested ifs for a while I decided to create a little user-interface which helped me to decrease the time for creating nested if-statements.
Even if this tools is just a little, little helper it may also be helpful for you, so I decided to publish it here:

Try the “Nested If Generator” now

Some screenshots and explanation:

At the beginning you can define the “fieldname” to be generated” and define your first if-statement:
Let’s assume you are checking the two fields “Age” and “Profession”:

Defining the first if-statement

Defining the first if-statement

If you want to add an additional if-clause just click on “Add another IF-block”:

Adding a second if-statement

Adding a second if-statement

As you can see when comparing the two screenshots above the “else-block” of the first statement was removed and replaced by an additional if-clause.

After some further if-blocks the configuration could look like as follows:

After adding several if-statements

After adding several if-statements

Now the last step is easy, change to the “Generated Code” tab and copy your code:

Generated Code to be used in QlikView

Generated Code

The Tool is offering three different “Formatting Styles”:

Single line formatting

Single line formatting

Single line formatting

If-statements formatted like this were the main-reason for creating this tool :)

Indent style with one line per condition

Indent style with one line per condition

Indent style with one line per condition

This is my preferred formatting-style for really large if-statements with complex conditions

Indent style with one line per if-statement

Indent style with one line per if-statement

Indent style with one line per if-statement

This is my preferred formatting-style for if-statements with short conditions like demonstrated in this example …

Have fun :)

Bookmark and Share

and tagged , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.

32 Comments