Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
amien
Specialist
Specialist

why does this RGB function not work? (sample now included)

=IF(NodeActive='N',RGB(10,10,10),RGB(70,130,180))

i only see the second color in my dimensions.

When i select only the NodeActive=J in a listbox .. then i only see the first color. But with no selection i see only the second color.

Thanks in advanced

10 Replies
Not applicable

Hi

The expression itself looks ok to me.
Do you have the field NodeActive as a dimension in your table?
If not, you probably get multiple values for that field when you don't have any selections.

/Fredrik

Not applicable

With no value selected, then the value of NodeActive is undefined (null). So with no selection you would expect to see the second colour.

Regards,

Gordon

amien
Specialist
Specialist
Author

the IF function is in a dimension ... not an expression. so there shouldnt be any multible values.

gorden . i understand what you mean.. but how can i make this work with no selection?

Miguel_Angel_Baeyens


Amien wrote:When i select only the NodeActive=J in a listbox .. then i only see the first color. But with no selection i see only the second color.


That's correct, because when no selections are done, NodeActive=N is false. Check as well current selection in the conditional, something like

if(NodeActive='N' AND GetFieldSelections(NodeActive) >= 1, RGB(10, 10, 10), RGB(70, 130, 180))


Change that depending on which colour do you want to see by default.



amien
Specialist
Specialist
Author

but i want to change to color based on no selection .. value is in a dimension

Miguel_Angel_Baeyens

For what it's worth, I suppose you mean you are drawing a chart (straight table, pivot table) and you want to change background colours? Please, specify your case. A dimension is a field, so your conditional should be based on fields, as well as it's possible to do it by checking value of a field, selection... where do you want to apply that color change?

amien
Specialist
Specialist
Author

companies are in the dimenisions .. i want the background of that company to be red if its not active anymore. if a company is active of not is based on the fieldNodeActive.. Working with the hierarcy function .. so i have some levels of companies as dimension.

i want to apply the color change in pivot .. in used dimensions and then in background color of a certain dimension

amien
Specialist
Specialist
Author

this is an example .. seems a hierarchy issue ... i'v created a normal pivot with rgb background color change for dimensions .. and one for a hierarchy function. Help really appropriated.

Anonymous
Not applicable

Hi Amien,

If you add an expression to the left chart, Active, you will see that all the values for Base = Base2 return No. If you do the same on the right chart and add the expression, Active_Hier, you'll see that the only row for Base2 that has Active_Hier=No is the one where it lacks a Node value in L2. Since there are two different values, Yes and No, the background color expression will determine that the value of Active_Hier is NOT No and hence the dimension background color will not be red.

There are man ways to skin a cat but if you only have values Yes and No for Active_Hier then you should be able to check for a minstring() to see if at least one of the values is 'No' and in that case color the dimension background.

Example:

=IF(aggr(minstring(Active_Hier),HQ, L1)='No',Red(),White())