RGB() returns an integer corresponding to the color code of the color defined by the three parameters: the red component r, the green component g, and the blue component b. These components must have integer values between 0 and 255. The function can be used in expressions to set or evaluate the color properties of a chart object.
Syntax:
RGB (r, g, b)
Return data type: dual
Arguments:
Arguments
Argument
Description
r, g, b
Red, green, and blue component values. A color component of 0 corresponds to no contribution and one of 255 to full contribution.
Information noteAll arguments must be expressions that resolve to integers
in the range 0 to 255.
If interpreting the numeric component and formatting it in hexadecimal notation, the values of the color components are easier to see. For example, light green has the number 4 278 255 360, which in hexadecimal notation is FF00FF00. The first two positions ‘FF’ (255) denote the alpha channel. In the functions RGB and
HSL, this is always ‘FF’ (opaque). The next two positions ‘00’ denote the amount of red, the next two positions ‘FF’ denote the amount of green, and the final two positions ‘00’ denote the amount of blue.
Enter the following expression in the Colors and legendproperties panel:
If (Sum(Sales)>Sum(Budget),RGB(255,0,0),RGB(100,80,120))
Result:
The following example displays the equivalent RGB values for values in hex format:
Load
Text(R & G & B) as Text,
RGB(R,G,B) as Color;
Load
Num#(R,'(HEX)') as R,
Num#(G,'(HEX)') as G,
Num#(B,'(HEX)') as B
Inline
[R,G,B
01,02,03
AA,BB,CC];
Result:
Text
Color
010203
RGB(1,2,3)
AABBCC
RGB(170,187,204)
Refer to Coloring a visualization to find examples of how to use the color functions in visualizations, as well as details on the visualizations that support color by expression.
Charts are objects where calculations, aggregations, and groupings can be made. Graphical visualizations, such as bar charts and pie charts are common examples, but also non-graphical objects such as pivot tables are charts.
A chart consists of dimensions and measures, where the measures are calculated once per dimensional value. If the chart contains multiple dimensions, the measures are calculated once per combination of dimensional values.