Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
hic
Former Employee
Former Employee

To make a chart in QlikView – in any Business Intelligence tool, for that matter – you need to have one or several dimensions; entities with discrete values that you use as grouping symbols. But where should you define these dimensions: In the script or in the object where the dimension is used?

In most cases, you will use an existing field as dimension, i.e. an attribute that exists in the source data. In such a case, the answer to the above question is easy: Just make sure to load the field in the script, and you're done.

But in some cases you want to use derived attributes: Attributes that do not exist in the source data but one way or another can be calculated from existing fields.

One example is the fields of the Master Calendar: Year, Month, etc. These can all be derived from a date found in the source data:

   Month(Date) as Month

   Year(Date) as Year

A more advanced example is if you want to classify or rank a field. The following expression returns ‘A’ for the 10 best customers and a ‘B’ for the rest:

   If(Aggr(Rank(Sum(Sales)),Customer)<=10,'A','B')

For such fields the above question is very relevant: Should they be calculated in the script and saved as fields, or should they be calculated on the fly in a sheet object?

Image2.png

 

There are pro:s and con:s with both approaches: A field calculated in the script is calculated once and for all, so it does not need to be re-calculated every time the user clicks. Hence, response times will be slightly shorter if the field is calculated in the script.

On the other hand, in some cases you want the field to be re-calculated every time the user clicks. A good example is the classification using Rank() above. Most likely you want this field to depend on the selection made: If you have selected a product, you want to see the classification of the customers given this selection. Such a number is in its nature dynamic and should be calculated every time the user clicks.

The key is whether the calculated field should be static or dynamic. The field Month is static: A specific date always belongs to the same month, irrespective of user selection. As opposed to a classification or a rank where the calculation usually should be dynamic, since the result potentially could change every time the user clicks.

Bottom line is that dynamic fields must be calculated in the chart or the list box. But for static fields it is better if they are calculated in the script, since precious CPU-time otherwise will be unnecessarily spent every time the user clicks.

HIC

 

Note: The Rank() function cannot be used in the script, so if you want to calculate a static rank in the script, you need to do it in a different way, using e.g. a combination of Order By and RecNo().

 

Further reading related to this topic:

Buckets

25 Comments
hic
Former Employee
Former Employee

You can create a memory statistics application. In it you have a field CalcTime that will give you a fair estimate. Note however, that if the object calculation is cached, the CalcTime will be zero.

HIC

0 Likes
7,454 Views
sakamsureshbabu
Creator
Creator

hi

in calculated dimension can we use conditions

give me exp....

0 Likes
7,454 Views
hic
Former Employee
Former Employee

What I use in the blog post, is in fact a calculated dimension with a condition:

     If(Aggr(Rank(Sum(Sales)),Customer)<=10,'A','B')

You can also have conditions in other ways. See e.g. my post on Buckets where I use a Pick() function for my condition.

HIC

0 Likes
7,454 Views
MWiciok
Creator
Creator

Hi.

Thank you for this post. I just want to add that there is one problem at calculated dimensions which you need to have in mind using them: be careful and avoid to use directly two or more dimensions on row-detail-level (i.e. end-start as difference). If you click in the chart you would select in all used dimensions.

0 Likes
7,454 Views
devarasu07
Master II
Master II

Hi,

Got requirement like below

need to calculate the grade based on calculated measure and user selected dynamic filter value.

Let's assume we have list box filter as country,Category,Week,size etc, Based on the dimension we need to calculate the Grade (Calculated dimension). would it be possible to derive below summary report by Grade

ABC Stock analysis by Grade (Expected output).jpg

problem statement:

The problem with calculated dimension is that unable to sort the RangeSum in the descending order and it's creating incorrect Grades.

For more details, i have shared my qlikview file in below thread,

Re: ABC Analysis in Qlikview

Thanks Deva

0 Likes
7,219 Views