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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
KarenBC
Contributor II
Contributor II

Dynamic column headers based on variable

Hi all,

Can i create a dynamic dimension in a qliksense table which is partially made up of a variable value?

e.g. if i have a variable (vSelected) which allows the user to select one of the following options:

  • PreviousDay
  • PreviousMonth
  • PreviousYear

and then have a single column in a static table which is set to display the dimension called 'PreviousDay_Field1', 'PreviousMonth_Field1', 'PreviousYear_Field1' etc

can i make the dimension dynamic e.g. '$(vSelected)_Field1', so the dimension shown is dependent on the selection made in the variable input box by the user? 

I will need this across many columns so cant make the '_Field1' element of the field name part of the variable.

e.g if the customer selects Previous Year, I will need to apply logic to the whole table to show:

PreviousYear_Field1

PreviousYear_Field2

PreviousYear_Field3 

if they select PreviousMonth i will want to show:

PreviousMonth_Field1

PreviousMonth_Field2

PreviousMonth_Field3 

etc

 

 

1 Solution

Accepted Solutions
Vegar
MVP
MVP

Are you sure that the variable holds exactly what you are expecting?

What happens if you try to generate the string 

='TableName.$(vSelected)_Field1'

does it return what you expect it to?

Is vSelected a string value or a variable that is expected to return a string based on functions?

View solution in original post

4 Replies
Vegar
MVP
MVP

Try using this:

[$(vSelected)_Field1]

KarenBC
Contributor II
Contributor II
Author

Thanks so much for the quick response Vegar, unfortunately i tried that.  I should add this table is qualified so i tried to use

=[TableName.$(vSelected)_Field1]

but I'm getting null values ( i get real values when i hard code the vSelected value)

Vegar
MVP
MVP

Are you sure that the variable holds exactly what you are expecting?

What happens if you try to generate the string 

='TableName.$(vSelected)_Field1'

does it return what you expect it to?

Is vSelected a string value or a variable that is expected to return a string based on functions?

KarenBC
Contributor II
Contributor II
Author

The variable is set based on the result of a Pick function, I was missing the '=' in my variable setting...!

Thanks again Vegar, you helped me figure out my mistake.  All working now