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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I script this?

I have a calendar conrol in my script and a list box in my application showing the Quarter.  The values in the list box are 1,2,3, & 4.  For a calculated dimension, I want to show some data based on the selection of the quarter in the list box.  For example, if the quarter selected = 3, then show X, if the quarter = 4 then show Y, etc.

Thanks,

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

I'm not a fan of calculated dimensions and I wouldn't reference the selections from the list box.  I'd build it as data.  I assume you have a calendar table with the CAL_QTR field in it.  I would add something like CAL_QTR_MONTH with the values you want.  Something like this, say:

pick(CAL_QTR,'MAR','JUN','SEP','DEC') as CAL_QTR_MONTH,

For performance, it's generally better to do this sort of thing in script than in charts.  From a maintenance standpoint, then it's in one place instead of potentially in multiple charts.  And as a general rule, I'd rather put complexity in my script than in my charts, even if it's the same level of complexity and there's no duplication.  I have a hard time putting my finger on why, though, other than the previous two reasons.

View solution in original post

4 Replies
Not applicable
Author

You can do this with conditional calculations or conditional layouts, depending on what you want your end result to look like. Do you have a sample file of what you are looking to achieve?

Not applicable
Author

The field for calendar quater in the list box is CAL_QTR, in the calculated dimesion of the chart I am looking for something like,

If the CAL_QTR selected inthe list box =3, then 'SEP', if the CAL_QTR selected = 1, 'MAR',

I am just not sure of the script when trying to reference selections made in the list boxes.

THanks,

Not applicable
Author

You could use something like this in the conditional layout:

=SubStringCount(Concat(CAL_QTR, '|'), '1') 

johnw
Champion III
Champion III

I'm not a fan of calculated dimensions and I wouldn't reference the selections from the list box.  I'd build it as data.  I assume you have a calendar table with the CAL_QTR field in it.  I would add something like CAL_QTR_MONTH with the values you want.  Something like this, say:

pick(CAL_QTR,'MAR','JUN','SEP','DEC') as CAL_QTR_MONTH,

For performance, it's generally better to do this sort of thing in script than in charts.  From a maintenance standpoint, then it's in one place instead of potentially in multiple charts.  And as a general rule, I'd rather put complexity in my script than in my charts, even if it's the same level of complexity and there's no duplication.  I have a hard time putting my finger on why, though, other than the previous two reasons.