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”:
If you want to add an additional if-clause just click on “Add another IF-block”:
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:
Now the last step is easy, change to the “Generated Code” tab and copy your code:
The Tool is offering three different “Formatting Styles”:
Single line formatting
If-statements formatted like this were the main-reason for creating this tool
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
This is my preferred formatting-style for if-statements with short conditions like demonstrated in this example …
Have fun
32 Comments