Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I would like to make colors consistent by value. Furthermore, I would like to define a map between values and colors once and use it with a function. So, I came with the idea that I will create a variable like this and use it in expression to define colors.
My variable would be like this:
set color = if($1=2022,'#1e90ff',
if($1=2021 ,'#9400d3',
if($1=2020 ,'#b22222',
if($1=2019 ,'#228b22',
if($1=2018 ,'#4682b4','#000000')))))
and I will put this in expression for color:
$(color(my_dim))
But there is a problem. I can't use it with master dimension 😞
In the definition of master dimension, it's not possible to define the color with an expression.
On the other hand in the expression for color, it's not possible to use the dimension value easily like $1, we should put the dimension value there. So, if I put the expression of master dimension inside the color expression it would be something like this:
$(color(if(dim_1=$(another_var),'Y','N')))
which means two expressions inside each other and it doesn't work.
Does anyone have a solution for my problem?
With Master Dimensions you don't need an expression. You can set the colors for each value of the Dimension individually and they will carry over to every chart you use them in if you wish. Simply Edit the Dimension and choose Value Colors like below.
It's just appropriate for a situation you don't want to change color for a lot of dimensions. One of the dimensions which I would like to change is the Year that exists in lots of apps. I would like to have consistent color in all apps in this way I should add color code for 20 different years in different apps. but with the solution I have in my mind, I can just add an expression like 'color(year)' into the master item.