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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
musketeers
Creator
Creator

use of dynamic variable in chart dimension

Hi, I have a variable which generates a filed name. This value of field name changes based on user filter selection. This field name is there in a table. I need to generate a bar chart and dimension is based on the field name generated by the variable.

I am using this variable in chart dimension but it says invalid dimension. This variable return the valid column name. 

Could any one please help here.

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer

In general is a variable usable to define a dimension - the return must just be looking as if the dimension were directly selected respectively be written (it's not mandatory the same).

In your case is something wrong. It might be the parameter which isn't properly specified or something else. You may take something like this as starting point:

var:
= 'Prod_' & '$1'

call:
[$(=$(var(1)))]

In the case that the field-name contained any spaces or special chars the return must be wrapped with [] or "" ...

View solution in original post

5 Replies
thomas598henry
Contributor
Contributor


@musketeers wrote:

Hi, I have a variable which generates a filed name. This value of field name changes based on user filter selection. This field name is there in a table. I need to generate a bar chart and dimension is based on the field name generated by the variable.

I am using this variable in chart dimension but it says invalid dimension. This variable return the valid column name. 

Could any one please help here.


Hello @musketeers,
It sounds like you're passing a field name as a string, but Qlik expects an actual field reference in the dimension. Try using `$(=YourVariable)` in the dimension expression to evaluate the variable dynamically. If that doesn’t work, consider using a calculated dimension or mapping logic to resolve the field name before chart rendering. You’re close—just need to bridge that dynamic gap. Bible Chat



Best Regards,
Thomas Henry

musketeers
Creator
Creator
Author

Hi Thomas, Thanks for your suggestion. The variable is vChartDimension(1).

Here I am passing parameter to this varaiabl;e as the expression is accepting numbers like 1, 2, 3 and based on this it returns the Field Name. Let say it return a field name Prod_1.

This field name can be changed when user select different filter values.

I am using this variable in chart dimension like below:

=$(vChartDimension(1))

It gives error that invalid dimension.

I used your suggestion

'=$(=vChartDimension(1))' but it return blank.

I have used this in If clause and used wildmatch function also but not working. If instead of using this variable I pass field name in wildmatch function, chart is working. I think chart dimension is unable to evaluate the variable.

What is the mapping logic you are talking about. If you can explain it further.

marcus_sommer

In general is a variable usable to define a dimension - the return must just be looking as if the dimension were directly selected respectively be written (it's not mandatory the same).

In your case is something wrong. It might be the parameter which isn't properly specified or something else. You may take something like this as starting point:

var:
= 'Prod_' & '$1'

call:
[$(=$(var(1)))]

In the case that the field-name contained any spaces or special chars the return must be wrapped with [] or "" ...

Adam_Romanowski
Partner - Creator
Partner - Creator

I think it's caused by brackets in variable name. Qlik interprets it as a function (obviously it does not exist) with 1 as argument.

Here:

https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/Introduction/guidelines-v...

You can find guidelines for naming conventions and characters such as ( ) are reserved.

 

Anyway, try this as dimension value of your chart:

[$(=replace('vChartDimension(1)','',''))]

It's a trick to force Qlik to interpret text as it is.

musketeers
Creator
Creator
Author

Hi Marcus, Thanks for your help. This has worked. This expression is working with all types of column (column with and without space).

Thanks for your help.