Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

How to get the dimensions of the current chart?

Hi community !

In a lot of my chart I use AGGR fonction like :

Sum(

Aggr(

Sum(Measure),

DimX,

Dim1,

Dim2

)

)

DimX is in all expressions and Dim1/Dim2/.../DimN not.

example :

Dim1Dim2Expression
ABB12

Problem : I would like to create a variable with the list of the chart dimensions (Dim1, Dim2 in my example).

  1. I have tried : concat(distinct GetObjectField(ValueLoop(0,10)), ', '), but when I have a lot of data, my app stop to work
  2. Another solution : if (not isnull(GetObjectField(0)), ',[$(=GetObjectField(0))]' & if (not isnull(GetObjectField(1)), ', [$(=GetObjectField(1))]' & if (not isnull(GetObjectField(2)), ', [$(=GetObjectField(2))]' & if (not isnull(GetObjectField(3)), ', [$(=GetObjectField(3))]' & if (not isnull(GetObjectField(4)), ', [$(=GetObjectField(4))]')))),''), but it's not great...

Thanks

Help users find answers! Don't forget to mark a solution that worked for you!
1 Solution

Accepted Solutions
marcus_sommer

I think you could reach a better performance if you outsorced this expression into a variable - getobjectfield had a second parameter for the objectid - then the calculation should be only done once and not for each row in the chart. With this you could spare the if-loops and prepare this string with text-functions like replace/left/right ... in this kind that a valid dimension-list would be returned which could be global used in many expressions:

vDimList:

=

GetObjectField(0, $1)  & ',  ' &

GetObjectField(1, $1)  & ',  ' &

GetObjectField(2, $1)  & ',  ' &

GetObjectField(3, $1)  & ',  ' &

GetObjectField(4, $1)  & ',  ' &

GetObjectField(5, $1)

Sum(

Aggr(

Sum(Measure),

$(=vDimList('CH01'))

)

)

I think the syntax will be actually not quite correct and needs some adjustments but it should work. Perhaps you used a second parameter for these variable with them the dimension-list would be cutted after n-dimensions or ...

GetObjectField(0, $1, $2)

$(=vDimList('CH01', 2)

- Marcus

View solution in original post

3 Replies
marcus_sommer

I think you could reach a better performance if you outsorced this expression into a variable - getobjectfield had a second parameter for the objectid - then the calculation should be only done once and not for each row in the chart. With this you could spare the if-loops and prepare this string with text-functions like replace/left/right ... in this kind that a valid dimension-list would be returned which could be global used in many expressions:

vDimList:

=

GetObjectField(0, $1)  & ',  ' &

GetObjectField(1, $1)  & ',  ' &

GetObjectField(2, $1)  & ',  ' &

GetObjectField(3, $1)  & ',  ' &

GetObjectField(4, $1)  & ',  ' &

GetObjectField(5, $1)

Sum(

Aggr(

Sum(Measure),

$(=vDimList('CH01'))

)

)

I think the syntax will be actually not quite correct and needs some adjustments but it should work. Perhaps you used a second parameter for these variable with them the dimension-list would be cutted after n-dimensions or ...

GetObjectField(0, $1, $2)

$(=vDimList('CH01', 2)

- Marcus

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II
Author

Thank you Marcus.

In all my expressions I would like to use just one variable and without parameters (it's easier to maintain).

I have tried :

concat(distinct GetObjectField(ValueList(0,1, 2, 3, 4)), ', ')

or

concat(distinct GetObjectField(SubField('0_1_2_3_4', '_')), ', ')

That work with a little sample of data (like the QlikView script test), but no in my app (50 000K of lines).

Aurélien

Help users find answers! Don't forget to mark a solution that worked for you!
marcus_sommer

I don't know a better way as to use an external variable. You don't need to use the parametrized variable-version but if you have more then one expression it will reduce a lot the effort for maintaining.

- Marcus