参考信息:用于计算的运算符和函数
语法规则
- 账户、计算和自定义指标。必填。在表达式中使用账户代码(而非名称)或计算代码。
- 必须用方括号括起来。Example:[1000_Assets]或[My_Quick_Ratio]。
- 版本(可选)使用以下语法:[code](version = [version name])以引用实例中定义的账户、计算或自定义指标的任何版本。例如:[headcount_FTE](version = [Forecast 2018]),其中Headcount_FTE是账户,Forecast 2018是版本。若未指定,则使用默认版本。 有关版本和顺序优先级的详细信息,请参见 概念:图表中的计算 。
- 必须用括号括起来。
- 版本名称有空格时,必须使用方括号。例如,必须将“Working Budget”用方括号括起来。“WorkingBudget”则不需要方括号。
- 运算符优先级:从左到右计算或括起d 括在括号中以先计算。
数学运算符
Operator | Description | Syntax |
|---|---|---|
+ | Adds two values. | [metric1] +
[metric2] |
- | Subtracts two values. | [metric1] -
[metric2] |
/ | Divides two values. | [metric1] /
[metric2] |
* | Multiplies two values. | [metric1] *
[metric2] |
% | Calculates the remainder (modulus) when dividing two
values. | [metric1] %
[metric2] |
^ | Raises the value on the left to the power of the value on the
right. For example, 5^ 2 = 25. | [metric1]
^2 |
比较运算符
将比较运算符与 iif 函数结合使用。Example:
iif([30_Net_Income] <= ([41_laptopRev] + [42_desktopRev] + [43_tabletRev]), [30_Net_Income], 40_Product_Revenue])
。Operator | Description | Syntax |
|---|---|---|
= | Checks if two values are equal. | [metric1] =
[metric2] |
<> | Checks if two values are not equal. | [metric1] <>
[metric2] |
< | Checks if the left value is less than the right value. | [metric1] <
[metric2] |
<= | Checks if the left value is less than or equal to the right
value. | [metric1] <=
[metric2] |
> | Checks if the left value is greater than the right value. | [metric1] >
[metric2] |
>= | Checks if the left value is greater than or equal to the right
value. | [metric1] >=
[metric2] |
BETWEEN | Checks if a value is between two other values. Minimum and
maximum values are included in the range. Use with the
AND operator. | [metric1] BETWEEN 0
AND [metric2] |
NOT BETWEEN | Checks if a value is not between the two other values. Minimum
and maximum values are included in the range. Use with the
AND operator. | [metric1] NOT BETWEEN
0 AND [metric2] |
AND | Compares two expressions and returns true if both expressions are
true. | ([metric1] >=
[metric2]) AND ([metric1] >= [metric3]) |
OR | Compares two expressions and returns true if either expression is
true. | ([metric1] >=
[metric2]) OR ([metric1] >= [metric3]) |
比较函数
函数 | 描述 | 示例 |
|---|---|---|
iif( 比较表达式 , true 表达式 , false 表达式 ) | 评估 比较 表达式。如果为 true,则返回 true 表达式 。否则,返回 false 表达式 。 | iif([metric1] > 10 AND [metric1] < 20, [metric2], [metric3]) |
计算函数
Function | Description | Example |
|---|---|---|
min( expression ,
expression ) | Returns the smallest value of two expressions. | min([metric1],
[metric2]) |
max( expression ,
expression ) | Returns the largest value of two expressions. | max([metric1],
[metric2]) |
sin( expression ) | Returns the sine of a metric or expression. Used in
Trigonometry. | sin([metric1]) |
cos( expression ) | Returns the cosine of a metric or expression. Used in
Trigonometry. | cos([metric1]) |
tan( expression ) | Returns the tangent of a metric or expression. Used in
Trigonometry. | tan([metric1]) |
abs( expression ) | Returns the absolute value of a metric or expression. Use to
convert negative numbers to positive numbers. | abs([metric1]) |
sqrt( expression ) | Returns the square root of a metric or expression. | sqrt([metric1]) |
round( expression ) | Rounds a numeric value to the nearest whole number. The
mid-point is rounded up. Examples:
| round([metric1]) |
round( expression ,
digits ) | Rounds a numeric value to a specified number of digits.
Positive digits round to the specified number
of decimal places. Negative digits round to
the nearest multiple of 10. Examples:
| round([metric1],
1) |
floor( expression ) | Returns a numeric value rounded down towards zero.
Examples:
| floor([metric1],
2) |
floor( expression ,
expression ) | Returns a numeric value rounded down towards zero, to the
nearest multiple of significance. Examples:
| floor([metric1],
2) |
ceiling( expression ) | Returns number rounded up away from zero. Examples:
| ceiling([metric1]) |
ceiling( expression ,
expression ) | Returns number rounded up, away from zero, to the nearest
multiple of significance. Examples:
| ceiling([metric1],
2) |
验证函数
函数 | 描述 | 示例 |
|---|---|---|
isnull( 表达式 , 空表达式 ) | 检查表达式是否为 null。如果为 true,则返回 null 表达式。否则返回 表达式 值。 | isnull([metric1], [metric2]) |
isinfinity( 表达式 , 无穷大表达式 ) | 检查 表达式 是否为无穷大(除以d 除零)。如果为 true,则返回 无穷大表达式 值。否则,返回表达式值值。 | isinfinity([metric1], [metric2]) |
isnan( 表达式 ,NaN 表达式 ) | 检查表达式是否为非数值(零除以零)。如果为 true,则返回 NaN 表达式 值。否则返回 表达式 值。 | isnan([metric1], [metric2]) |
isnrn( 表达式 ,NrN 表达式 ) | 检查表达式是否为实数,例如无穷大、非数值 (NaN) 或 null。如果为 true,则返回在 编号表达式 值。否则返回 表达式 值。 | isnan([metric1], [metric2]) |