Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Use Variable as Dimension

I want to create a variable that lists out several field options that would be incorporated into a table chart that would allow the user to change the dimension by changing the variable selection.  I want to avoid using an if statement as a calculated dimensior for performance reasons. 

28 Replies
Not applicable
Author

Hi John,

You were right, I have just downloaded and tried the QV v11 beta, and the "Enable Conditional" is there for dimension.

QVDimensionEnableConditional.JPG

Not applicable
Author

Hi John,

I have an associated problem: I have a complicated cashflow calculation where all the values have two versions, one basic and one including Skonto (rebate), named like this:

[Cash in from  Customers]

[Cash in from Customers_Skonto]

In charts I want to give the user the choice between the two value-versions, so I set up a variable vSkonto, which can be either empty or '_Skonto', by user-button-click.

The sum should look something like:  sum([Cash in from Customers$(vSkonto)])

so that the user can control which fieldname is used. The problem is: I can't get it to work syntaxwise. I tried in and out of brackets, with and without quotes - can't you do it that way at all, or am I missing a trick?

I know I could do it with an if-statement, but the formulas are already convoluted if-statements, so I'd prefer not to have to add another layer.

It would be really great if you could help me,

best,

Lenka

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Lenka,

this is one long thread, you might be better off opening a new one...

Anyway, I treid your expression, and it seems to work. I suspect you might have a syntax issue - perhaps an extra space or something like that... See attached sample

Oleg

Not applicable
Author

Privet Oleg,

spasibo bolshoe, you just saved me from a lot of extra coding!

It was indeed a syntax problem - when I set the variable, I used quotes, which QV then included in the variable (even though it didn't show them when I checked the variable in a textbox).

Best,

Lenka

Not applicable
Author

Dear John,

I read your answer and tried the solution that you gave but it does not work.

I have a variable named "vBucket" which is defined as :-

if(($(vPercentage))> 0 and ($(vPercentage))<=25 ,'0-25',

if(($(vPercentage))> 25 and ($(vPercentage))<=50 ,'26-50',

if(($(vPercentage))> 50 and ($(vPercentage))<=75 ,'51-75',

if(($(vPercentage))> 75 and ($(vPercentage))<=100 ,'76-100','Above 100'))))

Now the "vBucket" variable works perfectly fine in textbox but not in the pivot table as a dimension.

I tried "=[$(vBucket)]" but it fails and shows "-"

Please help

vishnus85
Partner - Creator
Partner - Creator

Helped me !

Not applicable
Author

U have downloaded your qvw file and pasted in user/documents/qlik/sense/apps.  It got converted to .qvf file but I am not able to see the app overview. I can see data manager view and data load editor view but cannot see app where I want to test your scenario of cyclic dimension. Please help

Anonymous
Not applicable
Author

Hi, I know you said leave the brackets off in the drop down, but I don't even get the option of a drop down.  Any idea as to why?

THnaks!

gucbacak81
Contributor
Contributor

=$(='['&(yourvariablename)&']')

try this if your variable evaluates as the field name you want to use as dimension