Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Amit_B
Creator II
Creator II

Set dymanic colors to dimension's values

Hi,

Is it possible to set the colors dynamically to the values ​​in the master item of a dimension?

For example, for an app that shows the current year and the last two years - the current year will always be shown in blue, the year before it in green and the last year in gray.

So if we look at 2024 then 2024 will appear in blue and 2023 in green. But if we look next year then 2025 will be the current year and will be shown in blue, 2024 will be shown in green and 2023 in grey.

I know it can be defined in this object by expression, but i have a lot objects so I'm trying to make it easier and define it in one place (in case they want to change the colors in the future).

Thanks.

Labels (4)
1 Solution

Accepted Solutions
PhanThanhSon
Creator II
Creator II

To assign a value to your variable, use the following format:

Set vColor = 'If(year=year(today()), rgb(0,0,255), ...)';

When referencing your variable, ensure to use the following syntax:

$(=vColor)

Best regards Son

 

View solution in original post

3 Replies
rubenmarin

Hi, as a workaround you can create a variable that stores the 'by expression' expression, and use this variable in every object, so in case it changes you only need to change the variable value.

Amit_B
Creator II
Creator II
Author

Thanks for the response.

How to set colors for values ​​in a formula? There is a smart way to do it or just simply use If and RGB functions?

If(year=year(today()), rgb(0,0,255), ...)

PhanThanhSon
Creator II
Creator II

To assign a value to your variable, use the following format:

Set vColor = 'If(year=year(today()), rgb(0,0,255), ...)';

When referencing your variable, ensure to use the following syntax:

$(=vColor)

Best regards Son