# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save \$300 before February 6: REGISTER NOW!
cancel
Showing results for
Did you mean:
Not applicable

hello all,

i have color in hexadecimal, is it possible to present the color?

many thanks,

avi

13 Replies
Partner - Creator II

Hi avi,

last year this question was answered here http://community.qlik.com/message/17746#17746 with "no" in terms of direct hex-input. But you can always convert hexadecimal colors to RGB using different tools - online calculators (for example here: http://drpeterjones.com/colorcalc/) or self-written functions (for example here: http://community.qlik.com/message/33594#33594).

regards,

Edgar

Not applicable
Author

hi,

i have seen these posts allready, but they are not so helpfull !!!,

thanks any way.

Partner - Creator II

may I ask why? you have to split up your hexadecimal color - first two digits for R, next two for G, last two for B. Calculation as implemented by Hector Munoz...

regards,

Edgar

Not applicable
Author

hello avifarkash,

you can translate your hex colors to RGB and use syntax similar to the following:

If(Avg(%Field) = 1, RGB(142,158,130), If(Avg(%Field) = 2, RGB(202,204,182), ...etc.

or you could make variables using the RGB function and write it like this instead:

If(Avg(%Field) = 1, \$(vGreenDk), If(Avg(%Field) = 2, \$(vGreenLt), ...etc.

or you could put the HEX value straight into your expression as follows:

If(Avg(%Field) = 1, '#8E9E82', If(Avg(%Field) = 2, '#CACCB6', ...etc.

dollar sign expansion on the second method is not necessary, just best practices.

best,

jo

Partner - Creator II

simple formula:  Num#('FF' & vHexColor,'(HEX)')

Use 6 hex digits in the place of vHexColor in the above formula.e.g  AABBCC would be
Num#('FFAABBCC','(HEX)')

In QlikView the color representation is 4 bytes long, where the first byte is the transparency. If you dont want transparancy then - like in the above example - start with "FF" and then put the rest of your Hex Color Code. The result is a valid color in QlikView.

(Hi avifarkashwould be nice if you mark this thread as "answered" ...)

Specialist II

Nice answer. I hope that avifarkash breaks their multi-year silence to answer!

Not applicable
Author

You can just use the hex number in color expression as it is.In color expression field enter hex number for example

'#F26E5B'

Champion III

Like this only

NOTE: HEXCODE should not contain '#' , if you have # then also add Purgechar()

=RGB(num(num#(left(HEXCODE,2),'(HEX)')) ,num(num#(mid(HEXCODE,3,2),'(HEX)')) ,num(num#(right(HEXCODE,2),'(HEX)')))

With Purgechar()

=RGB(num(num#(left(purgechar(HEXCODE,'#'),2),'(HEX)')) ,num(num#(mid(purgechar(HEXCODE,'#'),3,2),'(HEX)')) ,num(num#(right(purgechar(HEXCODE,'#'),2),'(HEX)')))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Partner - Champion III

Christof is correct. A colour value is simply a 32 bit (4-byte) number. Any expression which returns a 32 bit number can be used as a colour expression. RGB() and ARGB() also return a 32 bit number.

Splitting the hex number to feed into RGB() is messy and unnecessary. Use Christof's formula instead or a suitable adaptation to your requirements.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Community Browser