Compound Metric Calculation Formula Explanation


Compound metrics are calculated by superimposing one or more published derived metric(s). Refer to the following syntax description and conditions to create the compound metric calculation formulas:

  • The derived metrics referenced in the calculation formula must be all single-valued metrics or all multi-valued metrics.

  • If the derived metrics referenced in the calculation formula are all multi-valued metrics, the dimensions and statistical periods associated with all derived metrics must be the same.

  • If the derived metrics referenced in the calculation formula are all single-valued metrics, the dimensions associated with all derived metrics must be the same, but the statistical period can be different. The statistical period of the compound metric is ultimately determined according to priority (Priority from high to low: Beginning Of Life, This Year, Year To Date, This Month, Month To Date, Week To Date, This Day).

  • The dimension attributes in the calculation formula must be attributes of the derived metric to which this compound metric refers.

  • The compound metrics cannot be queried if the derived metrics in the calculation formula have not configured with query mapping groups.

  • Use a regular expression for interception, the metric needs to start with #, the dimension attribute needs to start with $, and the function needs to start with @.

  • Use legal arithmetic expressions.

    • Binary expressions support: addition +, subtraction -, multiplication *, division /, remainder %, and power ^.

      For example, #metric_id_1+#metric_id_2*$dim_attr%$dim_attr^3

    • Ternary expressions support: addition +, subtraction -, multiplication *, division /, remainder %, power ^, greater than >, less than <, greater than or equal to , less than or equal to , equal to ==, not equal to ! =.

      For example, #[metric_id_1] > #[metric_id_2] ? #[metric_id_1] : $dimAttr

  • The use of strings is supported in ternary expressions.

    For example, #[metric_id_1] > 0 ? ‘true’ : ‘false’

  • The use of logical operations is supported in ternary expressions, including and and or.

    For example, #[metric_id_1] > ‘select’ and #[metric_id_2] > 0 ? ‘true’ : ‘false’

  • The following special functions and function expressions are supported. Only single-valued derived metrics with a statistical period of This Day, Week To Date, This Month, and This Year; as well as multi-valued derived metrics with a statistical period of Year, Month, Week, and Day are supported in the following expressions.


    Function Name

    Expression Format and Description

    Meaning

    Year-on-Year Growth

    @yearOnYear(#metric, yyyy)
    Among the expression, yyyy can be blank, and if it is blank, the default calculation is the year-on-year growth from last year

    The year-on-year growth function is used to obtain the difference between the current period and the same period or a specified time of the previous year.
    When metric is a single-valued derived metric: You can call this function to obtain the year-on-year growth between the current month and the same month of a certain year.
    When metric is a multi-valued derived metric: You need to specify the start time and end time before you can query and obtain the year-on-year growth. For example, the metric value of monthly generation from March 2022 to June 2022 must be passed to the interface before the year-on-year growth in March, April, May, and June can be obtained.

    Year-on-Year Growth Rate

    @yearOnYearRate(#metric, yyyy)
    Among the expression, yyyy can be blank, and if it is blank, the default calculation is the year-on-year growth rate from last year

    Year-on-year growth rate = ((compound metric value for the current period - compound metric value for the same period last year or at a specified time)/compound metric value for the same period last year or at a specified time) x 100%. For example, for a certain metric, in January 2022 the year-on-year growth rate compared with the previous year = ((value of the metric in January 2022 - value of the metric in January 2021)/value of the metric in January 2021) x 100%.
    When metric is a single-valued derived metric: You can call this function to obtain the year-on-year growth rate between the current month and the same month of a certain year.
    When metric is a multi-valued derived metric: You need to specify the start time and end time before you can query and obtain the year-on-year growth rate. For example, the metric value of monthly generation from March 2022 to June 2022 must be passed to the interface before the year-on-year growth rate in March, April, May, and June can be obtained.
    When the value of the denominator in the formula is 0 or null, the data return result is null.

    Year-on-Year Value

    @samePeriod(#metric, yyyy)
    Among the expression, yyyy can be blank, and if it is blank, the default calculation is the year-on-year value from last year

    The Year-on-Year Value function is used to obtain the same period value of the metric in the last or specified year.
    When metric is a single-valued derived metric: You can call this function to obtain the year-on-year value of the last year.
    When metric is a multi-valued derived metric: You need to specify the start time and end time before you can query and obtain the year-on-year value. For example, the metric value of monthly generation from March 2022 to June 2022 must be passed to the interface before the year-on-year rate in March, April, May, and June can be obtained.
    When the value of the denominator in the formula is 0 or null, the data return result is null.

    Sequential Growth

    @compare(#metric)

    The change between specified periods or months or seasons. This function is used to obtain the difference between the values of a certain metric for the current and previous periods or months or seasons. For example, this function can be used to obtain the difference between this week’s and last week’s generation.
    When metric is a single-valued derived metric: You can call this function to obtain the sequential growth of the metric.
    When metric is a multi-valued derived metric: You need to specify the start time and end time before you can query and obtain the sequential growth. For example, the metric value of monthly generation from March 2022 to June 2022 must be passed to the interface before the sequential growth in March, April, May, and June can be obtained.

    Sequential Growth Rate

    @compareRate(#metric)

    The sequential growth rate = ((compound metric value of the current period - compound metric value of the previous period)/compound metric value of previous period) x 100%. For example, the sequential growth rate of a certain generation metric from this week to last week = ((the generation metric value of this week - the generation metric value of last week)/the generation metric value of last week) x 100%.
    When metric is a single-valued derived metric: You can call this function to obtain the sequential growth rate of the metric.
    When metric is a multi-valued derived metric: You need to specify the start time and end time before you can query and obtain the sequential growth rate. For example, the metric value of monthly generation from March 2022 to June 2022 must be passed to the interface before the sequential growth rate in March, April, May, and June can be obtained.
    When the value of the denominator in the formula is 0 or null, the data return result is null.

    Sequential Value

    @prevPeriod(#metric)

    The sequential value function is used to obtain the metric’s value for the last statistical period.
    When metric is a single-valued derived metric: You can call this function to obtain the sequential value of the metric.
    When metric is a multi-valued derived metric: You need to specify the start time and end time before you can query and obtain the sequential value. For example, the metric value of monthly generation from March 2022 to June 2022 must be passed to the interface before the sequential value in March, April, May, and June can be obtained.