Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating Color Expression for Years on Line Chart

Hi,

I'm having trouble creating a Color Expression to designate a color for each [Date] Dimension on a line chart.  With the data set at hand, the [Date] field is formatted as "MM/DD/YYYY".  Because of this, I had to create separate master dimensions for MONTH (x-axis of the chart), and YEAR (each line on the chart is a specific year from 2013-2016).  For Year, I used = YEAR([Date]), which has worked well.

I run into an issue when using a similar logic to set the Color Expression for each Year (i.e. I want the 2016 line to be X color, 2015 to be Y color, etc.)

Here's the color expression I'm using, which currently creates "misses" for all of the IF criteria, and changes each Year's line to Black... the last resort in the IF statement.  It would be nice if I could have pulled in the Master Dimensions I created, but that doesn't seem to be an option.

IF(YEAR([Date]) = '2013',

Red(),

IF(YEAR([Date]) = '2014',

Green(),

IF(YEAR([Date]) = '2015',

Blue(),

IF(YEAR([Date]) = '2016',

Yellow(),

Black()))))

Any help would be much appreciated.  Perhaps I'm going about the coloring the wrong way.

Labels (1)
2 Replies
reddy-s
Master II
Master II

Hi Kenneth,

Make use of the colormix() function to create complex colour coding expressions

https://www.youtube.com/watch?v=YasIe3VUJrg

Thanks,

Sangram.

Gysbert_Wassenaar

Year(Date) returns a number, not a string. So remove the single quotes around the year values. Also make sure that Date really is a date field and not a field with values that look like dates but are really just strings.


talk is cheap, supply exceeds demand