Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Allardata
Creator
Creator

Custom color by expression for two different expressions

I have a stacked bar-chart, with one dimension and two expressions.

Both expressions have a different meaning, but should be stacked to indicate a total.

By choosing color "Auto" or "Custom - Multicolored" I get the following visualization:

20150617 - CustomColorByExpression.PNG

Almost perfect... Just not these default colors blue and purple-red-ish.

In the rest of my dashboard I use two custom colors for the meaning of these expressions, which I want to apply to this bar-chart.

Choosing color "Custom - By expression" allows me to create an expression to color. But I cannot seem to make a color-expression that results in a different color for the first and second expression. The single color-expressions seems to be applied on both expressions equally and I don't know if (and how) I can actually make an "IF"-statement to address them separately...

20150617 - CustomColorByExpression2.PNG

One of the attempts include an IF statement that checks for a dimension-value particular for one of the expressions.

Another attempt includes checking COLUMN(1), also didn't get that to work.

How can I use the custom color expression to set different colors for expressions?

Labels (1)
16 Replies
Gysbert_Wassenaar

One way is to add a dummy dimension. For example:

Dummy:

LOAD * INLINE [

Dummy

A

B

];

You can then use that Dummy as second dimension in your chart together with only one expression like pick(match(Dummy, 'A','B'), sum(Foo), sum(Bar))

And you can then use a pick match for the color expression too: pick(match(Dummy, 'A','B'), Green(), RGB(200,50,150))

ps. wear shades if you use that second rgb color


talk is cheap, supply exceeds demand
Allardata
Creator
Creator
Author

Smart! And useful as a workaround in some cases for sure.

Yet selecting that bar-chart will result in a field-selection on "Dummy", right? As well as the pop-up when doing a mouse-over.

Gysbert_Wassenaar

You're right about the pop-up. So you might want to use another field name than Dummy. Something that better describes the measures represented by the values of the dummy dimension. Selecting a bar segment won't select the value in the Dummy dimension. See attached example.


talk is cheap, supply exceeds demand
demonioazul
Creator
Creator

Hi!

I have a similar issue, but my graph is not stacked...

2015-09-11 10_17_31-Qlik Sense Desktop.png

I used the Dummy in the Load Script provided by gwassenaar and it works ok (see the custom colours in my graph).

Problem is that Sense does not allow me to add an additional measure. The yellowish column should have other values (those from the measure I cannot add), not the same as the green one.

I am using a Dimension I created in the Master items (shown here are EA HP LP .... etc) in order to drill down (which btw uses the custom colours as well ) and the Dummy as Dimension as well - maybe due to the drill down dimension I cannot add more than one measure?

DummyAllWon:

LOAD * INLINE [

OpportunitiesAllWon

Sales Speed All Opps

Sales Speed Won Opps

];

pick(match([OpportunitiesAllWon],'Sales Speed All Opps','Sales Speed Won Opps'),

  green(),

     rgb(200,150,0)

    )

Thanks...!!

demonioazul
Creator
Creator

I switched for a non drill down Dimension and it does not allow me to add an additional measure

abhaysingh
Specialist II
Specialist II

Hi Gysbert,

Suppose you have two two measures and one dimension in it than how can we achieve it?.

Gysbert_Wassenaar

Suppose you have two two measures and one dimension in it than how can we achieve it?.

Can you explain what you mean with "two two measures"? The case of two measures and one dimension has been demonstrated above.


talk is cheap, supply exceeds demand
abhaysingh
Specialist II
Specialist II

Hi,

Color Change in qs

i have posted the sample qvf here pls look once..

reddy-s
Master II
Master II

Hi Allard,

I have answered the same question in this link : Re: How to use custom colours in a stacked bar chart with an attached QVF.

Capture.png

Hope this helps!

Thanks,

Sangram Reddy