Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to change graph colors based on calculated dimension values

I have a dimension that

 

aggr

(sum (Qtde) /
(
sum ({$<Ano_Mes = {$(=Max(Ano)&num(Max(Mes),'00') ) } >}  [Expectativa Vendas])
*
num(MaxString([Mês Filtro]))), PartNumber)

And  depends on the results I need   diferent collors in the pizza graphs.

6 Replies
MayilVahanan

HI

Can you explain more details? If possible, can you provide a sample file?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Gysbert_Wassenaar

Click on the + in front of the dimension and select Background Color. Then click on the Edit button. Now you can add an expression that calculates the color.

If( some_epxr = 12, red(), if some_epxr = 18.5, green(), blue() ))

Replace some_expr with your expression for the calculated dimension and change the comparison values as needed.

If you have a lot of values, you might want to use a pick-match combination instead of a nested if.


talk is cheap, supply exceeds demand
Not applicable
Author

I've already tried it, but haven't work.

Not applicable
Author

Sorry, unfortunately i have sensitive data and i cannot create a sample, however below i put more details

Dimension :

= if(

aggr(sum (Qtde) /
(
    sum ({$<Ano_Mes = {$(=Max(Ano)&num(Max(Mes),'00') )} >}

[Expectativa Vendas])
       *  num(MaxString([Mês Filtro]))), PartNumber)

<=Var_Cor_Penetracao_Amarelo,
      
dual('Crítico',1)  ,

   if(
  
   aggr(sum (Qtde) /
(
    sum ({$<Ano_Mes = {$(=Max(Ano)&num(Max(Mes),'00') )} >}

[Expectativa Vendas])
       *  num(MaxString([Mês Filtro]))), PartNumber)

<=Var_Cor_Penetracao_Laranja ,
     
dual('Regular',2),

if(
aggr(sum (Qtde) /
(
    sum ({$<Ano_Mes = {$(=Max(Ano)&num(Max(Mes),'00') )} >}

[Expectativa Vendas])
       *  num(MaxString([Mês Filtro]))), PartNumber)

<=Var_Cor_Penetracao_Marinho,
      
dual('Bom',3),
if(
aggr(sum (Qtde) /
(
    sum ({$<Ano_Mes = {$(=Max(Ano)&num(Max(Mes),'00') )} >}

[Expectativa Vendas])
       *  num(MaxString([Mês Filtro]))), PartNumber)

<=Var_Cor_Penetracao_Verde,
      
dual('Muito Bom',4),

  if(aggr(sum (Qtde) /
(
    sum ({$<Ano_Mes = {$(=Max(Ano)&num(Max(Mes),'00') )} >}

[Expectativa Vendas])
       *  num(MaxString([Mês Filtro]))), PartNumber)

>Var_Cor_Penetracao_Verde,
      
dual('Excelente',5)
 
)
)
)
)
)

Expression : Count (DISTINCT PartNumber)

I've already tried put the same expession ,  only chaging dual function by the collor (red(), blue etc),  in the background color propertie from this dimension and also in the background collor from the expression.

MayilVahanan

HI

In background color, use like this

if(

  

   aggr(sum (Qtde) / (sum ({$<Ano_Mes = {$(=Max(Ano)&num(Max(Mes),'00') )} >}[Expectativa Vendas]) *  num(MaxString([Mês Filtro]))), PartNumber) <= Var_Cor_Penetracao_Laranja , red(), blue())

And test, it will show the red color for first dimension and remaining the blue color?

May be any bracket miss while changing the dual() to color function.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Hi,

I tried your instruction on both background collor properties (dimension and expression) and also in the collor set.

Didn't work!

It could be solved getting dimension values . for example : if (Dimesion.label = 'x', red(), blue() ) however QV does not allow make this kind of reference to a calculated dimension. It only works when you are referencing dimensions defined with table fields.