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: 
stascher
Partner - Creator II
Partner - Creator II

Qlik Sense Custom Color by Dimension expression

Hello

I've got a stacked bar chart with two dimensions (First, Second) and one measure (Measure).

The chart's second dimension (Second) is specified by an expression and is based on the value of a variable:

fx = if ($(myVar)=1, [DimensionX], [DimensionY])

For the coloration I would like the colors to be based on the value(s) of the active dimension; ie, I need to dynamically color by dimension.


Under the Colors setting I chose Custom > By Dimension and specified the above expression in the Dimension expression box.

This does not work. All of the colors turn to gray!

Some observations from playing around:

  • specifying either [DimensionX] or [DimensionY] alone in the Dimension expression box displays colors, but obviously only when myVar is set to match the value I've specified there.  Since I need to dynamically switch between them, this is not a solution.
  • it appears that anything in the expression box other than just [DimensionX] or [DimensionY] fails. For example the expression: if(true(),[DimensionX]) fails even when myVar=1.
  • if there is anything (including whitespace!!!) either before or after the [DimensionX], that fails too.
  • It's like they put an expression editor in the Custom Colors By Dimension setting, but you're not supposed to put an expression in it.

Thanks for any suggestions.

16 Replies
stascher
Partner - Creator II
Partner - Creator II
Author

It appears that spaces in the names of the fields used as dimensions will break the expression parsing for Color by Dimension using expression.

=if (var=1,DimensionX,DimensionY)    //works

=if (var=1,DimensionX foo,DimensionY)  // does not

=if (var=1,[DimensionX foo],DimensionY)  // does not

=if (var=1,'DimensionX foo',DimensionY)  // does not

rubenmarin

Hi made some test and the problem comes when fields has an empty space. I couldn't find a solution, a workaround can be:

- renaming the field to remove blank spaces

- create another field based on this one given a non-blank-spaces  name

- wait for another community member that gives a solution

stascher
Partner - Creator II
Partner - Creator II
Author

I'm pretty sure this used to work properly in previous versions of QlikSense otherwise we'd have experienced this problem long ago. I'll bring it to the attention of Qlik support. Thank you very much for your efforts.

stascher
Partner - Creator II
Partner - Creator II
Author

A partial solution (only works in some cases) is to use double quotes around the field names:

=if (var=1,"DimensionX foo",DimensionY)


But it seems to be dependent on the "size" of the dimension.


Ruben, would you be so kind as to tell me what version of QlikSense you tested on?   Qlik claims to not see this problem on the latest version.   I was using v3.2 SR4.

rubenmarin

Hi Steven, I used the september version.

I can't try right now the double quote option.

stascher
Partner - Creator II
Partner - Creator II
Author

I've consulted with Qlik support. They've verified that it's a bug in Qlik and has been addressed in the latest version.

mansoorsheraz
Creator
Creator

Hi, 
When I use this "color by expression" feature QlikSense disables the Legends. Is there a way to overcome this issue so that we have the custom colored graphs and the legends stay on.

Regards.