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

Qlik Sense Color in Line Chart

Hi I want to color the line chart: above avg (reference line) as yellow, below avg as green. How can I do it? I tried color by measure with palette but was stuck with limited choices, I tried color by expression but get the whole line as green. Thanks in advance.LineChart.PNG

10 Replies
shraddha_g
Partner - Master III
Partner - Master III

What was the expression you used for color by expression?

felipedl
Partner - Specialist III
Partner - Specialist III

Hi Jessica,

Just do something like this for the expression in the Color by expression:

if(avg(Value)<0,red(),green()))

For some sample data i've put together, it gets me

Sample.png

Anil_Babu_Samineni

There is color section separate for "Reference Lines" you can pick any one from there

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ishanbhatt
Creator II
Creator II

Hi Jessica,

In Appearance property, you will find Color and legend section. In that select custom color and choose 'By expression' option from the dropdown list.

Then write below expression in expression space.

=if(Avg([Field Name)>133,Yellow(),Green()) .

Maybe this will solve your issue.

Anonymous
Not applicable
Author

Hi Anil I see the feature in available in Nov 2017. But this color setting is for reference line, I am looking for a way to color the measure. Thanks.

Anonymous
Not applicable
Author

Hi Ishan, this worked for static value. But if I replaced 133 with dynamic reference line expression it didn't work. Thanks.

Anonymous
Not applicable
Author

Hi Felip, this worked for static value. But if I replaced 133 with dynamic reference line expression it didn't work.

OmarBenSalem

well:

do

=if(Avg([Field Name)>YourExpressionForTheReferenceLine,Yellow(),Green()) .

Anonymous
Not applicable
Author

I added "all" in the dynamic reference line calculation and it worked. The reference line expression was to sum up the measure across the months and divide by month count. The reference line took the calculation without "all" because it was not impacted by dimension. Coloring condition was impacted by dimension though. So adding "all" would remove dimension impact. Thank you all for the input!