Please try to refer to this:
Especially Jonathan response:
Paulo , currently the getcurrentfield() isn't valid in Sense .
Would you be interested in a potential workaround ?
Its a little klugy instead of using getcurrentfield() i'm using a count(distinct total) to check how many field values are within my selection.
Say you have Country->City->Customer drill path and at the top level (when viewing countries) you want the pie to count the number of cities. When a user drills on one country and narrows the selection to just one country to see the cities within that country, then they want the measure to count the customers in each city.
Here is a conditional expression (think of it as long form version of getcurrentfield() ) to figure out which level of the hierarchy you are in.
In this example, the lowest level (customer) also shows the number of customers which doesn't make much sense but ... its just a quick example, you could add a nested IF to count ( distinct total city) = 1 and then display sum(SAles) or another metric at the lowest level.
Would this work for you ?
if (count( distinct total Country) > 1, Count(distinct City) , if ( count( distinct Country)=1 , Count(distinct Customer)))
Here is a 3 step drill visual of this in action:
You can also try to follow alvaro's logic:
It'd be great to have GetCurrentField function in Qlik Sense, unfortunately it's still not available.
Let me know what you think about this workaround using GetSelectedCount, which is supported in Qlik Sense. In my app I've created a drill-down group with the following time dimensions:
So, first of all, create a variable with the fields included in your drill-down group as follows:
vGetCurrentTimeFields = if(getselectedcount(Year)=0,'Year',
if(getselectedcount(Year)=1 and getselectedcount(Quarter)=0,'Quarter',
if(getselectedcount(Quarter)=1 and getselectedcount(MonthName)=0,'MonthYear',
if(getselectedcount(MonthName)=1 and getselectedcount(Date)=0,'Day',
I know what you might be thinking... field names are hardcoded. Yes, but with this simple logic you can retrieve the current field name within a drill down group!! Look at the following pictures. I created a bar chart in which the title is dynamic:
Hope this was helpful!
Yet another solution, use of inline island table instead of alternative dimensions:
see this example and adjust it to ur need:
What I would do is :
Creating an inline table:
Load * inline [
Now, In my presentation,
I'll have a selection field: Dimensions
and in my chrt, as a dimension:
If(Dimensions='Article', "My Article Dimension",
if(Dimensions='Customer', "My Customer Dimension"))
and as a title:
='Dimension is : '&Dimensions:
Hi Omar, here's an update on the matter:
There is actually a function, which allows you to reference Object's active field: https://help.qlik.com/en-US/sense/June2018/Subsystems/Hub/Content/Scripting/SystemFunctions/GetObjectField.htm
In my case it works in both cases (alternative and drill-down) with pick(match( :
=pick(match(GetFieldObject(0), '[FieldName1]', '[FieldName2]'),