Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Custom Colors by Year dimension

Is there a way to assign a color per year? I am creating a report with year as the dimension. Out of all time periods in the data, I have only gotten the past 3 years using set analysis. As a result, the default colors in the graph were quite to be in a similar shade maybe because it considered the other years not included in the set analysis However, I want the colors as distinct as possible. Any suggestions?

5 Replies
Not applicable

Re: Custom Colors by Year dimension

You can create the Color code for each Year.

Goto Expression, click the + sign and select Background color and write your custom expression like below:

Pick(Match(Year_Field,2015,2014,2013),RGB()for 2015,RGB()for 2014,RGB()for 2013)

sunny_talwar
Not applicable

Re: Custom Colors by Year dimension

To make this a little more dynamic, I would create a variable

vVar = Max(Year_Field)

and then use it like this:

Pick(Match(Year_Field, $(vVar), ($(vVar) - 1), ($(vVar) - 2)), RGB() for 2015,RGB() for 2014,RGB() for 2013)

Not applicable

Re: Custom Colors by Year dimension

Would this work on Qlik Sense?

sunny_talwar
Not applicable

Re: Custom Colors by Year dimension

I haven't worked with variables in Qlik Sense, but I think the new version allows for you to work with variables. If variables can be used the expression should work.

Not applicable

Re: Custom Colors by Year dimension

Yes

cf. video - Qlik Sense Using Variables interface - for more details about variables in QS11.


Define vVar  eg : 2016

In Appearance > Colors and legend > Colors Custom > By expression

Pick(Match(YEAR_FIELD,$(vVar),$(vVar)+1,$(vVar)+2),RGB(255,0,0),RGB(0,255,0),RGB(0,0,255))

Best regards,
L