Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
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')))
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!
'<=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.
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())))
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?
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)
Here's the *.qvf with the full data set. Thanks for your help.
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')))
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
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.