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> )
| Parameter | Type | Description |
|---|---|---|
color | Text | A colour written #RRGGBB, such as "#D89247". The short form #RGB, small letters and no # work too. |
red | Whole number | The colour's red, from 0 to 255. |
green | Whole number | Its green, from 0 to 255. |
blue | Whole number | Its 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
IMAGECOLORit 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" )
)
| #D89247 | 216, 146, 71 | #fc0 |
|---|---|---|
| peru | peru | gold |
Names for a palette
EVALUATE
VAR Swatches =
DATATABLE ( "Hex", STRING, { { "#B22222" }, { "#FFD700" }, { "#722F37" }, { "#2E8B57" } } )
RETURN
ADDCOLUMNS ( Swatches, "Name", COLORNAME ( [Hex] ) )
ORDER BY [Hex]
| Hex | Name |
|---|---|
| #2E8B57 | sea green |
| #722F37 | wine |
| #B22222 | fire brick |
| #FFD700 | gold |