Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Qlik Community,
I need some help with creating a legend for a bar chart where colors are defined using an expression.
In my bar chart, I'm using the following expression to set colors based on the Task SLA Status
:
pick(match([Task SLA Status], 'Met SLA', 'Not Met SLA'), green(), rgb(243,51,51))
This formula assigns green for 'Met SLA' and red (rgb(243,51,51
) for 'Not Met SLA'.
Now, I want to add a legend next to the bar chart showing:
How can I create this legend in Qlik Sense? Is there a way to manually define legend entries when using custom color expressions? Any suggestions or workarounds would be greatly appreciated!
Thank you in advance for your help!
@rajany089
1 - Create a master dimension from expression. In the Master items tab, enter:
aggr(distinct pick(match([Task SLA Status], 'Met SLA', 'Not Met SLA'), 'Met SLA', 'Not Met SLA')), [Task SLA Status])
**If your dimension only consists of these 2 values to which you want to assign the colors, simply place your [Task SLA Status] field directly without having to assign an expression to it, and then assign the colors equally to the example**
2 - After creating the dimension, assign the color to the values
3 - Switch to expression by dimension, choose the dimension created to activate the colors created in the master dimension
- Regards, Matheus
@rajany089
1 - Create a master dimension from expression. In the Master items tab, enter:
aggr(distinct pick(match([Task SLA Status], 'Met SLA', 'Not Met SLA'), 'Met SLA', 'Not Met SLA')), [Task SLA Status])
**If your dimension only consists of these 2 values to which you want to assign the colors, simply place your [Task SLA Status] field directly without having to assign an expression to it, and then assign the colors equally to the example**
2 - After creating the dimension, assign the color to the values
3 - Switch to expression by dimension, choose the dimension created to activate the colors created in the master dimension
- Regards, Matheus
@MatheusC Thank you, the solution was really helpful. However, even after selecting the color and updating the color by master dimension, the bar graph appears blank. Could you help me understand why this might be happening? I've also attached a picture below for reference.
@rajany089
How the master dimension was created? and how it is being used in the chart? Can you send a printout with this information? or a qvf file with fictitious data for example purposes.
From the image above, I can't help much.
- Matheus
Thank you so much! I was able to resolve this now. It was error at my end while using the created field.