Skip to main content
Announcements
Qlik Community Office Hours, March 20th. Former Talend Community users, ask your questions live. SIGN UP
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Author

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

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
Author

Would this work on Qlik Sense?

sunny_talwar

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
Author

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