Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
jesstungleumi
Contributor III
Contributor III

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
Partner

What was the expression you used for color by expression?

felipedl
Partner
Partner

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
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.

jesstungleumi
Contributor III
Contributor III
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.

jesstungleumi
Contributor III
Contributor III
Author

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

jesstungleumi
Contributor III
Contributor III
Author

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

OmarBenSalem
Partner
Partner

well:

do

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

jesstungleumi
Contributor III
Contributor III
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!