Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Why do legends disappear when I color a chart by expression (two scenarios)?

I need to color bar charts, pie charts, point maps, table fills, etc. consistently by a custom color set by:

  1. a single dimension, or
  2. two different dimensions on different tables that repeat common values High, Medium, and Critical.

but when specifying colors the legend disappears.


For one dimension (#1), I built a color by expression for each of the three measures,

if([Security Category Rating]= 'Medium', rgb(191, 191, 191),

if([Security Category Rating]= 'High', rgb(0, 32, 96),

if([Security Category Rating]= 'Critical', rgb(0, 176, 240),

'purple')))


When I use the expression instead of Qlik's built-in color, the legend disappears from the chart.

Vulnerabilities Bar Chart Qlik colors.pngVulnerabilities Bar Chart Expression colors.png


For two similar dimensions in different contexts (#2), I have columns that have the same implicit meaning and I want to filter by the same unique 'overall' category High, Medium, and Critical across different tables of things rated separately.  Normally in SSRS I define a bridge lookup table and a unique dimension table then connect the data as follows.

Location Summary Table

LocationOverall Equipment Criticality
AHigh
BMedium
CCritical
DCritical
EMedium
FCritical


Storage Table

LocationStorage Criticalities
AHigh; Medium
BMedium; Low
CCritical; High
DHigh; Critical
EMedium; Low
FCritical; Medium


Bridge Table

Overall CriticalityCriticality Variant
HighHigh; Medium
MediumMedium; Low
CriticalCritical; High
CriticalHigh; Critical
MediumMedium; Low
CriticalCritical; Medium
High

High

MediumMedium
CriticalCritical


Dim_Criticality

Overall Criticality
High
Medium
Critical


Relationships in SSRS like data modeling software:

  1. Bridge Table.[Overall Equipment Criticality] (>>many to one>) Dim_Criticality.[Overall Criticality]
  2. Storage Table.[Storage Criticalities] (>>many to one>) Bridge Table.[Criticality Variant]
  3. Bridge Table.[Criticality Variant] (>>many to one>) Dim_Criticality.[Overall Criticality]
  4. Location Summary Table.[Overall Equipment Criticality] (>>many to one>) Dim_Criticality.[Overall Criticality]


Then within my charts I would like to use the dimension with a common meaning in the two different tables as Dim_Criticality.[Overall Criticality].  In Qlik Sense's data manager, when creating associations listed above it said there is a circular reference. I think this is because I cannot appear to tell Qlik the directionality of any association relationship as being many to one. Is that correct?


To get around this must I merge the Bridge, Storage, and Location Summary tables?


I found another approach unique to Qlik that involves setting variables within the load script then referencing the variables in the color by expression.  This will not get around the first issue, granted, but is that method documented or useful to consider?

I need this to work in Qlik Sense Cloud, Qlik Sense Desktop, and Qlik Sense Enterprise server. 

1 Solution

Accepted Solutions
sandeep_sarawgi
Partner - Contributor III
Partner - Contributor III

When you custom color the dimension....you could insert a table with just the dimension and choose background color using expression.  Here you can write the expression or use color code from script via data modeling.

Sandeep Sarawgi

View solution in original post

5 Replies
sandeep_sarawgi
Partner - Contributor III
Partner - Contributor III

When you custom color the dimension....you could insert a table with just the dimension and choose background color using expression.  Here you can write the expression or use color code from script via data modeling.

Sandeep Sarawgi
brendacyoung174
Partner - Contributor
Partner - Contributor

Once again, QlikView is still superior to Qlik Sense on these development tasks.

Latif2030
Contributor
Contributor

I wish it would be possible to use a custom color, while still showing the dimension legend. This would save the need of duplicate work, by creating a new chart due to the lack of this functionality!

PadmaPriya
Support
Support

Please read this and it should solve the problem:

 

https://community.qlik.com/t5/Knowledge/Legend-will-be-disabled-when-The-expression-is-a-color-code-...

 

Thanks,

Padma Priya

Qlik Support

Help users find answers! Don't forget to mark a solution that worked for you! If already marked, give it a thumbs up!
AishwaryaVyas
Contributor III
Contributor III

I would like to use color by measure but legend based on dimension in stacked bar chart. Could anyone please suggest a way to do it. I can not define the dimension color because it keeps on changing with the filter.