Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, Is it possible to set the line color in graph based on the selection? for instance, if value a is selected then line color should be red else it should be same as background color.
In the chart properties, go to the expressions tab. Click on the little + next to the expression. Up pops a list of things you can modify. One of them is background color, which is actually the line color and not the background color. Click on it, and you'll note that the "Definition" box is available. You can type an expression in this box as long as it returns a color, and null() for the color will give you the default color. So for your case, maybe you want this:
if(Value='a',red(),white())
You can also specify RGB values if you don't like the stock colors:
if(Value='a',rgb(220,140,140),rgb(235,235,235))
But what I'm not understanding is why you'd use the background color. If they haven't selected value 'a', the line will simply disappear. Do you really want the line to just disappear?
Hmm, an alternate way to do that is to skip the background color expression and only calculate the line value if the value of 'a' is selected. Like if your line was sum(Sales):
if(Value='a',sum(Sales))
Then just color the line red using the color tab. Or did you want the red line regardless of selections as long as 'a' was ONE of the selections?
sum({<Value*={'a'}>} Sales)
You can expand the + sign in the Dimension and/or Expressions tab, and place a conditional line color. Here you can say like: if(a = 'P1', red())
In the chart properties, go to the expressions tab. Click on the little + next to the expression. Up pops a list of things you can modify. One of them is background color, which is actually the line color and not the background color. Click on it, and you'll note that the "Definition" box is available. You can type an expression in this box as long as it returns a color, and null() for the color will give you the default color. So for your case, maybe you want this:
if(Value='a',red(),white())
You can also specify RGB values if you don't like the stock colors:
if(Value='a',rgb(220,140,140),rgb(235,235,235))
But what I'm not understanding is why you'd use the background color. If they haven't selected value 'a', the line will simply disappear. Do you really want the line to just disappear?
Hmm, an alternate way to do that is to skip the background color expression and only calculate the line value if the value of 'a' is selected. Like if your line was sum(Sales):
if(Value='a',sum(Sales))
Then just color the line red using the color tab. Or did you want the red line regardless of selections as long as 'a' was ONE of the selections?
sum({<Value*={'a'}>} Sales)
Hello,
Thank you for the responses.
Both
a) if(Value='a',red(),white())
b) if(Value='a',sum(Sales))
solves my problem. however if I follow
a) then I was still able to see the labels, and when a line x was in red color because the condition in if statement was satisfied, if line y which was in while (because its if condition was not satisfied) intersected with x, then at the intersecting point of the red line there were white dots, which showed that there was another line.
b)I used the formula in b : if(Value='a',sum(Sales))
and it worked perfectly fine.
Thanks to both of you for taking time to respond to my question.