{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":36230,"path":"now-intelligence/reporting/metricbase-transforms.md","title":"MetricBase transforms","bundle":null,"doc_type":null,"release":"australia","body":"\n# MetricBase transforms\n\nTransforms enable you to visualize MetricBase data in different ways.\n\n## Available transforms\n\nAll transforms except for the **Label** transform are mathematical functions you can apply to the metrics data. Apply multiple transforms to create a transform chain.\n\n<table id=\"table_k4l_khm_hp2\"><thead><tr><th>\n\nTransform\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAdd\n\n</td><td>\n\nCalculates an outcome by adding the specified value to the data points in the dataset.\n\n</td></tr><tr><td>\n\nAverage\n\n</td><td>\n\nCalculates the arithmetic means of all currently selected metrics.\n\n</td></tr><tr><td>\n\nBottom\n\n</td><td>\n\nShows only the lowest specified number of values of the metric dataset.\n\n</td></tr><tr><td>\n\nChi-square\n\n</td><td>\n\nShows how well a statistical model fits the metric dataset.\n\n</td></tr><tr><td>\n\nCount\n\n</td><td>\n\nShows the count of data points within the metric dataset.\n\n</td></tr><tr><td>\n\nDecompose\n\n</td><td>\n\nSeparates out components of predictive models. You can decompose and request both the min and the max to get the lower and upper bounds of a predictive model.\n\n</td></tr><tr><td>\n\nDivide\n\n</td><td>\n\nCalculates an outcome by dividing the data points in the dataset by a specified value.\n\n</td></tr><tr><td>\n\nEnvelope\n\n</td><td>\n\nShows the minimum and maximum values of the metric dataset.\n\n</td></tr><tr><td>\n\nFilter\n\n</td><td>\n\nProduces a new series with values calculated using the given aggregation function over a sliding time window of the given duration. A sliding 15-minute average would use the Filter transform with the **Average** aggregation function and a duration of 15 minutes. Supported aggregation functions:\n\n-   AVG\n-   CHISQUARE\n-   LAST\n-   MAX\n-   MEDIAN\n-   MIN\n-   STDDEV\n\n</td></tr><tr><td>\n\nFit\n\n</td><td>\n\nGenerates a prediction model that can be used by the model-based trigger.\n\n</td></tr><tr><td>\n\nFractiles\n\n</td><td>\n\nReturns a new series with values representing the given percentiles of the underlying data. For example, to query for the 90th and 99th percentile response times, supply an array of \\[0.9,0.99\\].\n\n</td></tr><tr><td>\n\nInterpolate\n\n</td><td>\n\nConstructs new data points a specified duration to calculate an outcome.\n\n</td></tr><tr><td>\n\nLabel\n\n</td><td>\n\nEnables you to set a label for your transform.\n\n</td></tr><tr><td>\n\nLast\n\n</td><td>\n\nReturns the last defined value in the period window.\n\n</td></tr><tr><td>\n\nLog\n\n</td><td>\n\nCalculates the natural logarithm of all values in the dataset.\n\n</td></tr><tr><td>\n\nMax\n\n</td><td>\n\nShows the largest value at each point in time for the metric dataset.\n\n</td></tr><tr><td>\n\nMedian\n\n</td><td>\n\nShows the median of the metric dataset. The median separates the higher values of the metric dataset from the lower values.\n\n</td></tr><tr><td>\n\nMin\n\n</td><td>\n\nShows the smallest value at each point in time for the metric dataset.\n\n</td></tr><tr><td>\n\nMultiply\n\n</td><td>\n\nCalculates an outcome by multiplying the data points in the dataset by a specified value.\n\n</td></tr><tr><td>\n\nPartition\n\n</td><td>\n\nProduces a new series with values calculated using the given aggregation function over a fixed time frame of a given duration. Specify the **Base** \\(a timestamp\\) to align the partition window.Supported aggregation functions:\n\n-   AVG\n-   CHISQUARE\n-   LAST\n-   MAX\n-   MEDIAN\n-   MIN\n-   STDDEV\n\n</td></tr><tr><td>\n\nPredict\n\n</td><td>\n\nCompares predicted time-series data generated by the prediction model selected in the MetricBase Models table \\(mb\\_model\\) to real data. The predicted and real data can be graphed. Prediction triggers are based on the predicted values as well as thresholds. Thresholds are values above and below the predicted value. Real data that falls outside of those thresholds execute prediction triggers.\n\n</td></tr><tr><td>\n\nPut\n\n</td><td>\n\nCopies a time-series metric into a different MetricBase time-series metric, for example, `copyData('targetMetric').put()`.\n\n</td></tr><tr><td>\n\nResample\n\n</td><td>\n\nExpands or contracts the data to fit the given period. When you extend the period, the aggregation function is used to combine the data to fit the new period. When you shorten the period, the existing data is propagated to the underlying periods. Supported aggregation functions:\n\n-   AVG\n-   CHISQUARE\n-   LAST\n-   MAX\n-   MEDIAN\n-   MIN\n-   STDDEV\n\n</td></tr><tr><td>\n\nStandard Deviation\n\n</td><td>\n\nCalculates the standard deviation across the underlying data. Used to quantify the variation or dispersion of a set of data values in the metric dataset.\n\n</td></tr><tr><td>\n\nSubtract\n\n</td><td>\n\nCalculates an outcome by subtracting the specified value from the data points in the dataset.\n\n</td></tr><tr><td>\n\nSum\n\n</td><td>\n\nCalculates the sum of the data points within the metric dataset. See [Sum transform](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/now-intelligence/reporting/metricbase-transforms.md) for more information.\n\n</td></tr><tr><td>\n\nTop\n\n</td><td>\n\nShows only the highest specified number of values of the metric dataset.\n\n</td></tr></tbody>\n</table>## Sum transform\n\nA value at timestamp “T” denotes the value for the range \\(T-period, T\\). In your query, `sum()` gives the input series. You have one series and then you resample the original series into a new series with period = 1 day. When you resample the original series to a period, it creates two data points \\(2000-04-02T00:00:00Z and 2000-04-03T00:00:00Z\\). The value at 2000-04-02T00:00:00Z is 1 because there is one data point. The value at 2000-04-03T00:00:00Z is calculated by aggregating values in the range \\(2000-04-02T00:00:00Z, 2000-04-03T00:00:00Z\\]. The value is equals 3. \\[Omitted image \"sum-transform1.png\"\\] Alt text: Understanding the sum transform \\[Omitted image \"sum-transform2.png\"\\] Alt text: Resampled series\n\nIn this example, the result of\n\n```\nvar startTime = new GlideDateTime('2000-04-02 00:00:00');\nvar endTime = new GlideDateTime('2000-04-02 23:00:00');\ntransformer.metric('u_cost').sum().resample('SUM', GlideDuration('1 00:00:00'))\n```\n\nis \\[1, 3\\] rather than \\[4\\].\n\n```\n====== rest api result for GET ======\n{\n  \"seriesRef\": {\n    \"subject\": \"28e6bf5d73c233000355bccdbdf6a70c\",\n    \"table\": \"sn_cld_intg_aws_cost_usage\",\n    \"metric\": \"u_cost\"\n  },\n  \"label\": \"28e6bf5d73c233000355bccdbdf6a70c:sn_cld_intg_aws_cost_usage|u_cost\",\n  \"values\": [\n    {\n      \"timestamp\": \"2000-04-02T00:00:00Z\",\n      \"value\": 1\n    },\n    {\n      \"timestamp\": \"2000-04-02T01:00:00Z\",\n      \"value\": 1\n    },\n    {\n      \"timestamp\": \"2000-04-02T02:00:00Z\",\n      \"value\": 1\n    },\n    {\n      \"timestamp\": \"2000-04-02T03:00:00Z\",\n      \"value\": 1\n    },\n    {\n      \"timestamp\": \"2000-04-02T04:00:00Z\",\n      \"value\": 0\n    },\n    {\n      \"timestamp\": \"2000-04-02T05:00:00Z\",\n      \"value\": 0\n    },\n    ...\n    {\n      \"timestamp\": \"2000-04-02T23:00:00Z\",\n      \"value\": 0\n    },\n    {\n      \"timestamp\": \"2000-04-03T00:00:00Z\",\n      \"value\": 0\n    }\n  ]\n}\n```\n\n**Parent Topic:**[Create Core UI reports from MetricBase time-series data](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/now-intelligence/reporting/create-report-with-metricbase-data.md)\n\n"}}