Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Avoid multiple ifs

Hi,

I am new to qlikview and have a kind of situation where my expressions are having more than 10 nested if conditions,  thus charts are taking hell lot of time to open. All ifs' are result of the multiple filters provided in dashboard.


Please suggest me some other way round to decrease the opening time of charts.

Regards,

Navdeep Kumar

8 Replies
morgankejerhag
Partner - Creator III
Partner - Creator III

It depends on how your ifs are structured. There are other functions such as pick() that can be used together with for example match().

Can you show us how the ifs look like?

Not applicable
Author


Few suggestions:

1. Use if...else statements in the load script and not in the expression of a chart.

2. See if you could utilize peek(). interval match(), group by functions.

Remember if..else is memory and CPU intensive so you should always use them in the load script and avoid using in expressions whenever possible.

MarcoWedel

Hi,

best you provided sample data/app to get specific answers to your question.

regards

Marco

Not applicable
Author

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

Not applicable
Author

Hi,

Thanks for your valuable time. It is something like that..

if(GetFieldSelections(vA)='Local Currency',

if(GetFieldSelections(vB)='Include',

if(GetFieldSelections(vC)='Include',

.

.

.

then few more if conditions under each of them.

Conditions are based on user selection.

Please let me know the other way round and I will definetly explore pick and interval match().

Regards,

Navdeep

Not applicable
Author

Thanks Bomma,

But here my problem is something different. I want to avoid Ifs, but as all are getting calculated on the fly bcz of GetFieldSelections(). Is there any way to reduce them ? if yes, thn plz guide me.

Regards,

Navdeep

Not applicable
Author

Hi,

Waiting for the solution. Appreciate some help here.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Attach full expression.

Regards,

Jagan.