OpenBI Docs Buy

COLORNAME OpenBI

The nearest named colour to a colour, given as #RRGGBB or as red, green and blue.

Group: Images and colours. OpenBI’s own: DAX has no function of this name.

Syntax

COLORNAME ( <color> )
COLORNAME ( <red>, <green>, <blue> )
ParameterTypeDescription
colorTextA colour written #RRGGBB, such as "#D89247". The short form #RGB, small letters and no # work too.
redWhole numberThe colour's red, from 0 to 255.
greenWhole numberIts green, from 0 to 255.
blueWhole numberIts blue, from 0 to 255.

Returns

Text. The name of the nearest named colour, in small letters: peru, fire brick, sea green.

Remarks

  • The names are those web pages know, written as words (dark sea green), and a few more, wine colours among them: burgundy, claret, merlot.
  • Nearest means the smallest difference to the eye, roughly. A shade far from every named colour still gets the closest name there is.
  • Where two names share a shade, the first one wins: #FF00FF is fuchsia, #00FFFF aqua.
  • A blank colour gives BLANK. A text that is not a colour, a red, green or blue outside 0 to 255 or with a fraction, and two arguments instead of one or three, are errors.
  • With IMAGECOLOR it names the main colour of a picture.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

One colour, three ways

EVALUATE
ROW (
    "#D89247", COLORNAME ( "#D89247" ),
    "216, 146, 71", COLORNAME ( 216, 146, 71 ),
    "#fc0", COLORNAME ( "#fc0" )
)
#D89247216, 146, 71#fc0
peruperugold

Names for a palette

EVALUATE
VAR Swatches =
    DATATABLE ( "Hex", STRING, { { "#B22222" }, { "#FFD700" }, { "#722F37" }, { "#2E8B57" } } )
RETURN
    ADDCOLUMNS ( Swatches, "Name", COLORNAME ( [Hex] ) )
ORDER BY [Hex]
HexName
#2E8B57sea green
#722F37wine
#B22222fire brick
#FFD700gold

IMAGECOLOR, IMAGECOLORS, UNICHAR.

Last updated · OpenBI Studio 0.3.74