Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
peter_turner
Partner - Specialist
Partner - Specialist

Changing field colours using a 'lookup' table

Hello Everyone,

I'm looking for afew ideas or thoughts on this problem.

I would like to use a custom lookup table with multiple keywords for multiple tables, and define their colours.
E.g
Table, FieldName, Keyword, Colour
Data, AlertStatus, Alarm, "RGB(255,0,0)"
Data, AlertStatus ,Normal,"RGB(0,255,0)"
TimeDate, Day, Saturday, "RGB(255,255,0)"
TimeDate, Day, Sunday, "RGB(255,255,0)"

I was looking for a better method instead of editing each dimension and having a long static IF chain, such as:
If fieldtext='Alarm', RGB(xxx), else (if blarrrr, RGB(xxx), else if(blar etc etc


The ideal solution would be some script that will change every table/chart that may contain the correct Table.Fieldname reference and assign colours to keywords.
My colour lookup table will change and have new keywords / tables, so I have to avoid setting things manually if possible.

Any thoughts or ideas would be greatly appropriated.

Thanks, Peter.

3 Replies
Not applicable

Can I add a me to to this

prieper
Master II
Master II

Think that the LOOKUP-function should be of help:

lookup( fieldname, matchfieldname, matchfieldvalue [, tablename] )

Returns the value of fieldname corresponding to the first occurrence of the value matchfieldvalue in the field matchfieldname.

Fieldname, matchfieldname and tablename must be given as strings (e.g. quoted literals).

The search order is load order unless the table is the result of complex operations such as joins, in which case the order is not well defined.

Both fieldname and matchfieldname must be fields in the same table, specified by tablename. If tablename is omitted the current table is assumed.

If no match is found, null is returned.

Example:

lookup('Price', 'ProductID', InvoicedProd, 'pricelist')

HTH
Peter

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

It might be a little hard to do it completely generic, with "table", "FieldName", and Keyword logic - for example, what if you present a multi-dimensional chart, and you have two contradicting conditions?

However, you can arrange something along these lines. Specifically for Graphs (not tables), you can define all default colors with formulas, and determine the color using conditional functions. You'd need to assign your colors to certain specific data entities, not generically to anything.

For tables, this feature wouldn't work, because Table Charts are not using the same Colors. You'd have to do something similar in the attribute of each Dimension and Expression.