Today, I will cover some basics on how to create dimension groups for your QlikView applications. I will also talk about using GetCurrentField to make your charts behave more seamlessly with your groups. This info is must-have for any serious QlikView developer.
When you build a chart, you typically will use at least one dimension field so that the aggregation in your expression gets calculated for each value in your dimension list. This is a simple concept that we can expand on.
Grouped dimensions can be used in any chart. I also use them sometimes in listboxes. They save space if the users understand how they function.
In QlikView, grouped dimensions come in two flavors.
Drill-Down – When a user makes selections resulting in one possible value, the dimension changes to the next dimension field.
Creating a Cyclic Dimension Group
Create a group name, choose the radio button for Cyclic Group and then add the fields you want in your group. Note that the order of these fields will represent the order in which users can normally switch between them with the top field being default.
Now let’s create a drill-down dimension. This time we will build the group from the chart. Create a line chart and when you get to the dimensions tab, you can select Groups in the bottom left.
I am often asked which style is better and my answer is always “it depends on your audience”. Most sophisticated users will prefer a cyclic group because they can directly control the dimension being displayed regardless of the selections.
With that said, I have had situations where the client wanted the same chart done both ways.
You might run into a situation where a field in your group is not sorting correctly when in use. Take the example below where we have used Quarter Year. Sorting this alphabetically is wrong and numerically does not work either. Either way, we cannot determine the sort from our normal chart Sort tab.
Sometimes, an expression you create needs to interact with the fields you are using for dimensions. This is typical for expressions with aggr functions. So what do you do when your dimension can change? Well, of course, there is a function for that. Let’s cover a few applications of GetCurrentField.
This expression could be entered in the General tab for Window Title.
Resulting in a dynamic title that changes with the drill down.
In another use-case, we have created a line chart that measures profit over time. And instead of using a static dimension like date, I instead created a cyclic group that allowed the user to cycle from Year, to Month, to Date. This is a very common requirement. But in addition, the users require a reference line 75% to the maximum value of the chart and also at the 25% point. This would be pretty simple but how do we know what the highest value is as we cycle from one dimension to another.
I created both lines and here is the final chart. As I click the cycle button, the reference lines recalculate to the new maximum value.
Here is some interesting further reading on the GetCurrentField function.
QlikView Maven – Expression Knows Which Cycle Group Field is Active
QlikShare – System/Meta Data Functions in QlikView – Part 1