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

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
qlik2
Contributor
Contributor

Using the pick() function in Dimension Declaration

Hi everybody,

I'm trying to implement the pick() function in the declaration of a dimension in a VizLib Bar Chart, as follows:

- I make a filter pane with CalendarDate, WeekName, MonthName, YearName
- I open up the expression editor for the dimension and fill in:
=Pick(vSelection.CalendarDimension, [CalendarDate], [CalendarDate], [WeekName], [MonthName])
- vSelection.CalendarDimension is a variable with integer values 1,2,3,4 as CalendarDate, WeekName, MonthName, YearName are selected respectively in the filter pane.

So what I would like to see happen, is that when is select a MonthName, the Bar Chart's time dimension should be WeekName. And when I select WeekName, the Dimension should become CalendarDate. However, the Dimension does not seem to change when selecting a different dimension in the filter pane.

Is this possible to do? If so, how should I do this?

Thanks in advance,

Raf

1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

5 Replies
sunny_talwar
MVP
MVP

Would you be able to create a sample where you are trying to do this to explore this?

qlik2
Contributor
Contributor
Author

I quickly made an example app with an inline load statement. 

A brief example of the inline load statement:

Table:
LOAD * INLINE [
Day , Week , Month , Year , Sales
1,1,jan,2019,351
...
4,3,mar,2019,4
...
4,3,mar,2017,12

So we have the following sets :  Year={2019,2018,2017}  ,  Month={jan,feb,mar} ,  Week={1,2,3} , Day={1,2,3,4} and Sales ranging from 1 to 1000.

Then we have a variable CalendarDim defined as:

If([Day], 1, If([Week], 2, If(Not(Isnull([Month])), 3, If([Year], 4))))

And we have a Bar Chart (with a filterpane above it) with Sum(Sales) as measure and the following dimension:

Pick(CalendarDim,Day,Day,Week,Month)


Only now, when I select a year, the bar chart gives me the values 1,2,3,4 on the dimension axis, instead of the expected jan,feb,mar (the months). 

Hope this gives you insight

sunny_talwar
MVP
MVP

Try attached

qlik2
Contributor
Contributor
Author

Awesome, it seems to be working just fine. Thanks for the quick solution.

rickster1502
Contributor
Contributor

Can the specific dimension inside the pick can be sorted?