Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Consistent colors across charts

This seems like a simple problem but I am having trouble with it.  I want similar measures to have similar colors across two charts in my application.

2017-04-27_11-20-00.jpg

I have tried changing the order of the series in the bar chart. I have "persistent colors" checked in the pie chart.  Nothing seems to work.


To make matters even more confounding I did some sample data for the last 4 months to post here and that dataset seemed to work the way it should.


Hoping someone can shed some light here.


TIA.


1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

You will have to create a new variable in the Data Load Editor for the different categories. Let us say you create a new variable as follows:

if(hours_eeg_upload_to_report <=2, '<=2'

, if(hours_eeg_upload_to_report >2 AND hours_eeg_upload_to_report <=12, '2-12'

, if(hours_eeg_upload_to_report >12 AND hours_eeg_upload_to_report <=24, '12-24'

, '24+'))) as hours_eeg_upload_to_report_categories

----------------------------------------------------------------------------------------------------------------------

-Now in the Front End, you can call 'hours_eeg_upload_to_report_categories' as your dimension.

-Your measure remains the same.

-In the Colors and Legend --> By Expression, use this following formula:

if(hours_eeg_upload_to_report_categories = '<=2', 'blue',

     if(hours_eeg_upload_to_report_categories = '2-12', 'red',

          if(hours_eeg_upload_to_report_categories = '12-24', 'yellow', 'green')))

View solution in original post

7 Replies
Anonymous
Not applicable
Author

Hi Brian,

You can force Qlik to assign specific colors by choosing Appearance --> Colors and Legend --> By Expression and then entering a formula in the "Expression" bar. The formula can be something like this:

if(measure='<2', 'blue',

  if(measure='2-12', 'red',

    if(measure='12-24', 'green',

       if(measure='>24', 'yellow'))))

You can also use hexadecimal colors. For example, in the code above - you can replace 'yellow' with '#daa520'.

If you follow the same procedure in all the charts you want to be consistent with each other, your issue should be solved! Hope this helps!

Happy Qlik-ing!

Anonymous
Not applicable
Author

'<=2', '2-12', etc. are dimensions, not measures and I have tried choosing custom colors in the pie chart -> 'By Dimension and entering a formula like you have here and it has no effect on the chart.

2017-04-27_15-22-01.jpg

Here is the expression...

if(hours_eeg_upload_to_report <=2, blue()

, if(hours_eeg_upload_to_report >2 AND hours_eeg_upload_to_report <=12, red()

, if(hours_eeg_upload_to_report >12 AND hours_eeg_upload_to_report <=24, Yellow()

, Green())))

Anonymous
Not applicable
Author

1. Can you choose "By expression" instead of "By dimension" and see if it works?

2. Can you show me what you have as your dimension and measure?

Anonymous
Not applicable
Author

1. All the slices are green

2. For the pie chart:

Dimension:

if(hours_eeg_upload_to_report <=2, '<=2'

, if(hours_eeg_upload_to_report >2 AND hours_eeg_upload_to_report <=12, '2-12'

, if(hours_eeg_upload_to_report >12 AND hours_eeg_upload_to_report <=24, '12-24'

, '24+')))

Measure:

Count(myKey)

Anonymous
Not applicable
Author

Here's the *.qvf with the full data set.  Thanks for your help.

Anonymous
Not applicable
Author

You will have to create a new variable in the Data Load Editor for the different categories. Let us say you create a new variable as follows:

if(hours_eeg_upload_to_report <=2, '<=2'

, if(hours_eeg_upload_to_report >2 AND hours_eeg_upload_to_report <=12, '2-12'

, if(hours_eeg_upload_to_report >12 AND hours_eeg_upload_to_report <=24, '12-24'

, '24+'))) as hours_eeg_upload_to_report_categories

----------------------------------------------------------------------------------------------------------------------

-Now in the Front End, you can call 'hours_eeg_upload_to_report_categories' as your dimension.

-Your measure remains the same.

-In the Colors and Legend --> By Expression, use this following formula:

if(hours_eeg_upload_to_report_categories = '<=2', 'blue',

     if(hours_eeg_upload_to_report_categories = '2-12', 'red',

          if(hours_eeg_upload_to_report_categories = '12-24', 'yellow', 'green')))

Anonymous
Not applicable
Author

Sweet, That worked! 

The final expression turned out to be:

if(hours_eeg_upload_to_report_categories = '<=2', '#4476A9'

, if(hours_eeg_upload_to_report_categories = '2-12', '#117833'

, if(hours_eeg_upload_to_report_categories = '12-24', '#DDCB75'

, '#CB6676')))

This site was helpful in getting the color codes

Get Colors from Image

I tried the same expression in the stacked bar chart but it did not work.  I was forced to match the colors in the bar chart.