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

Announcements
Data Works for AI is here - Join the discussion and enter to win a pair of Qlik kicks: Join the Conversation!
cancel
Showing results for 
Search instead for 
Did you mean: 
lee_
Contributor II
Contributor II

variable as a dimension in a table

Hello 

I've trying to create a simple table where the user can select a value from a custom filter and the 1st dimension of a table changes to that selected dimension.

 

Created an island table of friendly names

Load * inline[

DimName, DimNum

Red, 1

Blue,2

Green, 3];

 

created a variable for selection 

vCustomDimName  =only(DimNum)

 

created a variable to change into correct dimension name

vCustomNameSwitch = 

if($(vCustomDimName)  =1, 'RED', 

if($(vCustomDimName)  =2, 'BLUE', 'GREEN'))

 

created a filter that uses 'DimName' , which looks as expected with friendly names Red, Blue, Green

if i create a text box with $(vCustomNameSwitch)  it correctly changes it to the proper dimension name  RED,BLUE,GREEN

 

then thought i could just created a table and use 

$(vCustomNameSwitch)   as my dimension name but it errors with invalid dimension , any ideas what's going wrong, or have I taken the wrong approach?

many  thanks

many thanks 

Labels (2)
3 Replies
rubenmarin
MVP
MVP

Hi, having a dimension like [$(vCustomNameSwitch)] should work if the value of vCustomNameSwitch exactly matches the name of the field,it should be in the sema casing as the field name, have you confirmed it has the exact same name?

Sample attached

Vegar
MVP
MVP

I notice that the field names in the pick list are in Capitalized case, but I'm the if statement you use UPPER case. Could that be an root cause to your problem? The value needs to be identical to the field name.

Chanty4u
MVP
MVP

Hi try this 

=Pick(

    Only(DimNum),

    [RED],

    [BLUE],

    [GREEN]

)

 

Or as suggested by vegar try this 

=Pick(

    Match(Upper(Only(DimName)), 'RED', 'BLUE', 'GREEN'),

    [RED],

    [BLUE],

    [GREEN]

)