Finding Clues in Data with Qlik
Finding Clues in Data with Qlik

GetObjectField() function and Alternate Dimensions

One of the features I love in QlikView is cyclic dimension group. This was not present in earlier versions of Qlik Sense and then it was substituted with alternate dimensions.

Well, sort of. There are a few things which are still missing in Qlik Sense when you compare alternate dimensions to cyclic dimension groups. First, you cannot define alternate dimension as a master measure, so you need to define them for each chart individually (you can define dimension groups – cyclic or drill down – in QlikView). Second, you cannot use alternate dimensions in tables (you can in QlikView). And third, you cannot control chart measures according to which dimension of the alternative ones is currently selected, because there’s no GetCurrentField(GroupName) function (there are no “groups” which exist in QlikView). At least that’s what I thought until I found function called GetObjectField(), completely by chance while looking for something else at the help site.

So I dropped everything to try this function and see if it can work for my scenario. And – surprise, surprise – it can! But first thing first. Let’s see what the help site says:
GetObjectField([index])This function returns the name of the dimension. Index is an optional integer denoting which of the used dimensions that should be returned.
(source: https://help.qlik.com/en-US/sense/February2019/Subsystems/Hub/Content/Sense_Hub/Scripting/SystemFunctions/GetObjectField.htm)

This sounds like it does exactly what GetCurrentField() function, right? Yes! So I finally had a solution for one of my pains. A typical requirement was to show a share of a measure relative to total. A typical use case for the TOTAL qualifier in an aggregation function. This could be made dynamic in QlikView by using GetCurrentField() function, for example like this:

 Sum(Patients)/Sum(TOTAL <$(=GetCurrentField([Dimensions]))> Patients)

Cyclic groups in QlikView
Cyclic groups in QlikView

I thought this was not possible in Qlik Sense, but it is, thanks to GetObjectField(), which does exactly the same thing. So I simply added a couple of alternative dimensions to a bar chart, slightly adjusted the measure calculation, and voila:

Sum(Patients)/Sum(Total <$(=GetObjectField(0))> Patients)

Alternative dimensions in Qlik Sense
Alternative dimensions in Qlik Sense

There’s one thing you need to be careful about though. In Qlik Sense, since alternative dimensions are not defined as a group, ALL chart dimensions are alternatives to each other. So whenever you want to show grouped or stacked bar chart as in my example and use alternative dimensions, users can choose wrong dimension very easily and get unexpected visualization. That’s why I also tried a different approach, with variable and buttons changing contents of that variable. I then used the variable as chart dimension getting exactly the same result with two benefits: 1) I now can have a “fixed” dimension and 2) this can be used in tables as well!

Use a button to pick your dimension
Use a button to pick your dimension

Easy, right? I also created a sample app to record these animations which you can download in case I did not explain everything clearly. Enjoy!

Leave a comment

Your email address will not be published. Required fields are marked *

7 thoughts on “GetObjectField() function and Alternate Dimensions”