Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Highlighted
jtay
New Contributor III

coloring lines in chart

I have a chart that shows a count by month with overlapping years.

I've been asked to specify the line color by year.

2015 = blue

2016 = yellow

2017 = red

I've been trying to color by dimension and by expression but I'm missing something.

This color by expression gives me yellow for all lines:

if(Year(Date)='2015'

  ,blue()

  ,if(Year(Date)='2016'

     ,yellow()

     ,red()

     )

  )

If I don't try and specify anything, and color by dimension using   =Year(Date) then this is what the chart looks like.

I could use a little help.  thanks.

1 Solution

Accepted Solutions
jtay
New Contributor III

Re: coloring lines in chart

I had this just about right... my problem was with taking a derivative of a field in the if statement.

I added Year(Date) as ydate  to the load script and got this working correctly.

if(ydate='2015' ,blue(),

if(ydate='2016' ,'#f0e68c','#ff0000'))

3 Replies
vasiliy_beshent
Contributor III

Re: coloring lines in chart

Can you please provide soma part of your app, so then i will help you.

Or you just can see how i make that already in this topic How to color the monthly bar for each year diff color , for easy visulisation purpose. It must work same way.

jtay
New Contributor III

Re: coloring lines in chart

I had this just about right... my problem was with taking a derivative of a field in the if statement.

I added Year(Date) as ydate  to the load script and got this working correctly.

if(ydate='2015' ,blue(),

if(ydate='2016' ,'#f0e68c','#ff0000'))

vasiliy_beshent
Contributor III

Re: coloring lines in chart

Well good. Mark some post as helpful if you got yuor solution.