Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

Conditionally show dimension based on cyclic expression

Hi all,

i am trying to solve a problem but not having much luck!

i have 9 expressions in a cyclic group and a handful of dimensions (1 cyclic that contains 3 fields, and 2 standard dimensions).

what i want is to conditaionally show or hide the 2 standard dimensions based on the expression that has been selected from the cyclic group.

so for example,

Dimensions

Cyclic  (Field A,B,C)

Dim A

Dim B

Expressions

Cyclic (containing the following)

>Volume

>Sales

i always want the cyclic dimension showing, but if the user was to select the expression cyclic group and choose 'Volume' then i would want Dim A to hide and Dim B to show.

if the user was to choose Sales from the cyclic expression then i would want to hide Dim A and show Dim B.

does anyone know if this is possible please?

2 Replies
sasiparupudi1
Master III
Master III

Please load a sample

Peter_Cammaert
Partner - Champion III
Partner - Champion III

There is no easy way (except by using macros) to obtain the currently selected expression from a group. An expression group also doesn't have a label, so GetCurrentField() won't work.

However, you can build upon a workaround that was initially suggested by JohnW in How to get the used expression?. It goes as follows:

  • In your script, create a date island with two fields that have the names of your expressions both as name and as content. If for example you use the example from your OP, call the fields Volume and Sales and add a singe row with Volume and Sales
  • Create a cyclic dimension group that includes these two fields. Add the group as a dimension to your chart. Place the group icon somewhere on your chart.
  • Pull the two expressions out of the expression group, and either combine them in a single IF() construct (one expression switches between two real expressions, depending on the currently selected field in the newly created dimension group - see below) or leave them as they are and give each a conditional show depending on which field is selected in the cyclic group you came to create.
  • Define two real dimension groups: one with fields A and C and one with fields B and C.
  • Add those two dimension groups to your chart, but give each one the same conditional show expression as the conditional show of the corresponding chart expression.
  • Now try it out.

For getting the currently selected dimension from a cyclic group, you can use the following:

=GetCurrentField(DimensionGroupName)

which you can use to correctly label the following combined expression:

=IF (GetCurrentField(DimensionGroupName)='Sales', Sum(SalesData), Sum(VolumeData))

IF you keep two separate expressions, use conditional show expressions like:

GetCurrentField(DimensionGroupName) = 'Sales'

GetCurrentField(DimensionGroupName) = 'Volume'


Note: of course the fields in the new Cyclic group cannot have the same names as the Sales and Volume fields in your facts table.


Best,


Peter