Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Function does not change color when the value is null or zero

Hello everybody!

Please help me with the following question:

I have a table where the text color changes according to the value of the cell. However, when the value is null or zero, the formula does not work. How can I do?

Table:

DEPTO. QTDE. PERCENTUAL
ENG. 8 50%
TRAF. 5 31%
PED. 2 13%
MKTAS 1 6%
CAU 0 0%
CRT 0 0%
PA 0 0%
Total 16 100%

Code:

if(siglaDepartamento='ENG.',

          RGB(0,168,0),

          if(siglaDepartamento='CRT',

                    RGB(255,0,0),

                    if(siglaDepartamento='TRAF.',

                              RGB(255,0,255),

                              if(siglaDepartamento='CAU',

                                        RGB(0,255,0),

                                        if(siglaDepartamento='MKTAS',

                                                  RGB(128,0,0),

                                                  if(siglaDepartamento='PA',

                                                            RGB(255,255,0),

                                                            if(siglaDepartamento='PED.',

                                                                      RGB(0,255,255),

                                                                      if(siglaDepartamento='VV',

                                                                                RGB(132,0,0)

                                                                      )

                                                            )

                                                  )

                                        )

                              )

                    )

          )

)

Go!

2 Replies
johnw
Champion III
Champion III

This doesn't solve the problem you're asking about, but I'd do this:

DepartmentColors:
LOAD * INLINE [
singlaDepartamento,R,G,B
ENG,0,168,0
CRT,255,0,0
TRAF,255,0,255
CAU,0,255,0
MKTAS,128,0,0
PA,255,255,0
PED,0,255,255
W,132,0,0
];

And simplify your color expression to this:

rgb(R,G,B)

But as I said, it won't solve the problem where the 0 and null rows don't pick up the color.  What I just did an hour ago was to prevent myself from having null or 0.  Something along these lines:

rangesum(if(len(siglaDepartmento),.0000001),count(Something))

It worked for me, but there must be a better solution.

Not applicable
Author

Thanks for the suggestion! But did not resolve the issue. The problem is related to the date filter. See the image below:

'CAU' and 'PA' does not appear colored as they are not contained in either category.

Some susgestão?

IMG.jpg