

# Gaining insights with machine learning (ML) in Amazon Quick Sight
Gaining insights with ML

Amazon Quick Sight uses machine learning to help you uncover hidden insights and trends in your data, identify key drivers, and forecast business metrics. You can also consume these insights in natural language narratives embedded in dashboards. 

Using machine learning (ML) and natural language capabilities, Amazon Quick Sight Enterprise Edition takes you beyond descriptive and diagnostic analysis, and launches you into forecasting and decision-making. You can understand your data at a glance, share your findings, and discover the best decisions to achieve your goals. You can do this without developing teams and technology to create the necessary machine learning models and algorithms. 

You likely have already built visualizations that answer questions about what happened, when, where, and provide drill down for investigation and identification of patterns. With ML insights, you can avoid spending hours manually analyzing and investigating. You can select from a list of customized context-sensitive narratives, called *autonarratives*, and add them to your analysis. In addition to choosing autonarratives, you can choose to view forecasts, anomalies, and factors contributing to these. You can also add autonarratives that explain the key takeaways in plain language, providing a single data-driven truth for your company. 

As time passes and data flows through the system, Amazon Quick Sight continually learns so it can deliver ever more pertinent insights. Instead of deciding what the data means, you can decide what to do with the information it provides. 

With a shared foundation based on machine learning, all of your analysts and stakeholders can see trends, anomalies, forecasts, and custom narratives built on millions of metrics. They can see root causes, consider forecasts, evaluate risks, and make well-informed, justifiable decisions. 

You can create a dashboard like this with no manual analysis, no custom development skills, and no understanding of machine learning modeling or algorithms. All this capability is built into Amazon Quick Sight Enterprise Edition.

**Note**  
Machine learning capabilities are used as needed throughout the product. Features that actively use machine learning are labeled as such. 

With ML Insights, Amazon Quick Sight provides three major features:
+ **ML-powered anomaly detection** – Amazon Quick Sight uses Amazon's proven machine learning technology to continuously analyze all your data to detect anomalies (outliers). You can identify the top drivers that contribute to any significant change in your business metrics, such as higher-than-expected sales or a dip in your website traffic. Amazon Quick Sight uses the Random Cut Forest algorithm on millions of metrics and billions of data points. Doing this enables you to get deep insights that are often buried in the aggregates, inaccessible through manual analysis. 
+ **ML-powered forecasting** – Amazon Quick Sight enables nontechnical users to confidently forecast their key business metrics. The built-in ML Random Cut Forest algorithm automatically handles complex real-world scenarios such as detecting seasonality and trends, excluding outliers, and imputing missing values. You can interact with the data with point-and-click simplicity.
+ **Autonarratives** – By using automatic narratives in Amazon Quick Sight, you can build rich dashboards with embedded narratives to tell the story of your data in plain language. Doing this can save hours of sifting through charts and tables to extract the key insights for reporting. It also creates a shared understanding of the data within your organization so you make decisions faster. You can use the suggested autonarrative, or you can customize the computations and language to meet your unique requirements. Amazon Quick Sight is like providing a personal data analyst to all of your users.

**Topics**
+ [

# Understanding the ML algorithm used by Amazon Quick Sight
](concept-of-ml-algorithms.md)
+ [

# Dataset requirements for using ML insights with Amazon Quick Sight
](ml-data-set-requirements.md)
+ [

# Working with insights in Amazon Quick Sight
](computational-insights.md)
+ [

# Creating autonarratives with Amazon Quick Sight
](narratives-creating.md)
+ [

# Detecting outliers with ML-powered anomaly detection
](anomaly-detection.md)
+ [

# Forecasting and creating what-if scenarios with Amazon Quick Sight
](forecasts-and-whatifs.md)

# Understanding the ML algorithm used by Amazon Quick Sight
Understanding the ML algorithm


|  | 
| --- |
|  You don't need any technical experience in machine learning to use the ML-powered features in Amazon Quick Sight. This section dives into the technical aspects of the algorithm, for those who want the details about how it works. This information isn't required reading to use the features.   | 

Amazon Quick Sight uses a built-in version of the Random Cut Forest (RCF) algorithm. The following sections explain what that means and how it is used in Amazon Quick Sight.

First, let's look at some of the terminology involved: 
+ Anomaly – Something that is characterized by its difference from the majority of the other things in the same sample. Also known as an outlier, an exception, a deviation, and so on.
+ Data point – A discrete unit—or simply put, a row—in a dataset. However, a row can have multiple data points if you use a measure over different dimensions.
+ Decision Tree – A way of visualizing the decision process of the algorithm that evaluates patterns in the data.
+ Forecast – A prediction of future behavior based on current and past behavior.
+ Model – A mathematical representation of the algorithm or what the algorithm learns.
+ Seasonality – The repeating patterns of behavior that occur cyclically in time series data.
+ Time series – An ordered set of date or time data in one field or column.

**Topics**
+ [

# What's the difference between anomaly detection and forecasting?
](difference-between-anomaly-detection-and-forecasting.md)
+ [

# What is RCF?
](what-is-random-cut-forest.md)
+ [

# How RCF is applied to detect anomalies
](how-does-rcf-detect-anomalies.md)
+ [

# How RCF is applied to generate forecasts
](how-does-rcf-generate-forecasts.md)
+ [

# References for machine learning and RCF
](learn-more-about-machine-learning-and-rcf.md)

# What's the difference between anomaly detection and forecasting?


Anomaly detection identifies outliers and their contributing drivers to answer the question "What happened that doesn't usually happen?" Forecasting answers the question "If everything continues to happen as expected, what happens in the future?" The math that allows forecasting also enables us to ask "If a few things change, what happens then?" 

Both anomaly detection and forecasting begin by examining the current known data points. Amazon Quick Sight anomaly detection begins with what is known so it can establish what is outside the known set, and identify those data points as anomalous (outliers). Amazon Quick Sight forecasting excludes the anomalous data points, and sticks with the known pattern. Forecasting focuses on the established pattern of data distribution. In contrast, anomaly detection focuses on the data points that deviate from what is expected. Each method approaches decision-making from a different direction. 

# What is RCF?


A *random cut forest* (RCF) is a special type of *random forest* (RF) algorithm, a widely used and successful technique in machine learning. It takes a set of random data points, cuts them down to the same number of points, and then builds a collection of models. In contrast, a model corresponds to a decision tree—thus the name forest. Because RFs can't be easily updated in an incremental manner, RCFs were invented with variables in tree construction that were designed to allow incremental updates. 

As an unsupervised algorithm, RCF uses cluster analysis to detect spikes in time series data, breaks in periodicity or seasonality, and data point exceptions. Random cut forests can work as a synopsis or sketch of a dynamic data stream (or a time-indexed sequence of numbers). The answers to our questions about the stream come out of that synopsis. The following characteristics address the stream and how we make connections to anomaly detection and forecasting:
+ A *streaming algorithm *is an online algorithm with a small memory footprint. An online algorithm makes its decision about the input point indexed by time **t** before it sees the **(t\$11)-**st point. The small memory allows nimble algorithms that can produce answers with low latency and allow a user to interact with the data.
+ Respecting the ordering imposed by time, as in an *online* algorithm, is necessary in anomaly detection and forecasting. If we already know what will happen the day after tomorrow, then predicting what happens tomorrow isn't a forecast—it's just interpolating an unknown missing value. Similarly, a new product introduced today can be an anomaly, but it doesn't necessarily remain an anomaly at the end of the next quarter. 

# How RCF is applied to detect anomalies


A human can easily distinguish a data point that stands out from the rest of the data. RCF does the same thing by building a "forest" of decision trees, and then monitoring how new data points change the forest. 

An *anomaly* is a data point that draws your attention away from normal points—think of an image of a red flower in a field of yellow flowers. This "displacement of attention" is encoded in the (expected) position of a tree (that is, a model in RCF) that would be occupied by the input point. The idea is to create a forest where each decision tree grows out of a partition of the data sampled for training the algorithm. In more technical terms, each tree builds a specific type of binary space partitioning tree on the samples. As Amazon Quick Sight samples the data, RCF assigns each data point an anomaly score. It gives higher scores to data points that look anomalous. The score is, in approximation, inversely proportional to the resulting depth of the point in the tree. The random cut forest assigns an anomaly score by computing the average score from each constituent tree and scaling the result with respect to the sample size. 

The votes or scores of the different models are aggregated because each of the models by itself is a weak predictor. Amazon Quick Sight identifies a data point as anomalous when its score is significantly different from the recent points. What qualifies as an anomaly depends on the application. 

The paper [Random Cut Forest Based Anomaly Detection On Streams](http://proceedings.mlr.press/v48/guha16.pdf) provides multiple examples of this state-of-the-art online anomaly detection (time-series anomaly detection). RCFs are used on contiguous segments or “shingles" of data, where the data in the immediate segment acts as a context for the most recent one. Previous versions of RCF-based anomaly-detection algorithms score an entire shingle. The algorithm in Amazon Quick Sight also provides an approximate location of the anomaly in the current extended context. This approximate location can be useful in the scenario where there is delay in detecting the anomaly. Delays occur because any algorithm needs to characterize "previously seen deviations" to "anomalous deviations," which can unfold over some time. 

# How RCF is applied to generate forecasts


To forecast the next value in a stationary time sequence, the RCF algorithm answers the question "What would be the most likely completion, after we have a candidate value?" It uses a single tree in RCF to perform a search for the best candidate. The candidates across different trees are aggregated, because each tree by itself a weak predictor. The aggregation also allows the generation of quantile errors. This process is repeated **t** times to predict the **t**−th value in the future. 

The algorithm in Amazon Quick Sight is called *BIFOCAL*. It uses two RCFs to create a CALibrated BI-FOrest architecture. The first RCF is used to filter out anomalies and provide a weak forecast, which is corrected by the second. Overall, this approach provides significantly more robust forecasts in comparison to other widely available algorithms such as ETS. 

The number of parameters in the Amazon Quick Sight forecasting algorithm is significantly fewer than for other widely available algorithms. This allows it to be useful out of the box, without human adjustment for a larger number of time series data points. As more data accumulates in a particular time series, the forecasts in Amazon Quick Sight can adjust to data drifts and changes of pattern. For time series that show trends, trend detection is performed first to make the series stationary. The forecast of that stationary sequence is projected back with the trend. 

Because the algorithm relies on an efficient online algorithm (RCF), it can support interactive "what-if" queries. In these, some of the forecasts can be altered and treated as hypotheticals to provide conditional forecasts. This is the origin of the ability to explore "what-if" scenarios during analysis. 

# References for machine learning and RCF


To learn more about machine learning and this algorithm, we suggest the following resources:
+ The article [Robust Random Cut Forest (RRCF): A No Math Explanation](https://www.linkedin.com/pulse/robust-random-cut-forest-rrcf-math-explanation-logan-wilt/) provides a lucid explanation without the mathematical equations. 
+ The book [*The Elements of Statistical Learning: Data Mining, Inference, and Prediction*, Second Edition (Springer Series in Statistics)](https://www.amazon.com/Elements-Statistical-Learning-Prediction-Statistics/dp/0387848576) provides a thorough foundation on machine learning. 
+ [http://proceedings.mlr.press/v48/guha16.pdf](http://proceedings.mlr.press/v48/guha16.pdf), a scholarly paper that dives deep into the technicalities of both anomaly detection and forecasting, with examples. 

A different approach to RCF appears in other AWS services. If you want to explore how RCF is used in other services, see the following:
+ *Amazon Managed Service for Apache Flink SQL Reference: *[RANDOM\$1CUT\$1FOREST](https://docs.aws.amazon.com/kinesisanalytics/latest/sqlref/sqlrf-random-cut-forest.html) and [RANDOM\$1CUT\$1FOREST\$1WITH\$1EXPLANATION](https://docs.aws.amazon.com/kinesisanalytics/latest/sqlref/sqlrf-random-cut-forest-with-explanation.html)
+ *Amazon SageMaker Developer Guide: *[Random Cut Forest (RCF) Algorithm](https://docs.aws.amazon.com/sagemaker/latest/dg/randomcutforest.html). This approach is also explained in [The Random Cut Forest Algorithm](https://freecontent.manning.com/the-randomcutforest-algorithm/), a chapter in [Machine Learning for Business](https://www.amazon.com/Machine-Learning-Business-Doug-Hudgeon/dp/1617295833/ref=sr_1_3) (October 2018). 

# Dataset requirements for using ML insights with Amazon Quick Sight
Dataset requirements

To begin using the machine learning capabilities of Amazon Quick Sight, you need to connect to or import your data. You can use an existing Amazon Quick Sight dataset or create a new one. You can directly query your SQL-compatible source, or ingest the data into SPICE. 

The data must have the following properties: 
+  At least one metric (for example, sales, orders, shipped units, sign ups, and so on). 
+  At least one category dimension (for example, product category, channel, segment, industry, and so on). Categories with NULL values are ignored.
+ Anomaly detection requires a minimum of 15 data points for training. For example, if the grain of your data is daily, you need at least 15 days of data. If the grain is monthly, you need at least 15 months of data. 
+ Forecasting work best with more data. Make sure that your dataset has enough historical data for optimal results. For example, if the grain of your data is daily, you need at least 38 days of data. If the grain is monthly, you need at least 43 months of data. Following are the requirements for each time grain:
  + Years: 32 data points
  + Quarters: 35 data points
  + Months: 43 data points
  + Weeks: 35 data points
  + Days: 38 data points
  + Hours: 39 data points
  + Minutes: 46 data points
  + Seconds: 46 data points
+ If you want to analyze anomalies or forecasts, you also need at least one date dimension. 

If you don't have a dataset to get started, you can download this sample dataset: [ML Insights Sample Dataset VI](samples/ml-insights.csv.zip). After you have a dataset ready, create a new analysis from the dataset.

# Working with insights in Amazon Quick Sight
Adding insights

In Amazon Quick Sight, you can add ready-to-use analytical computations to your analysis as widgets. You can work with insights in two ways:
+ **Suggested insights**

  Amazon Quick Sight creates a list of suggested insights based on its interpretation of the data you put into your visuals. The list changes based on context. In other words, you can see different suggestions depending on what fields you add to your visual and what type of visual you choose. For example, if you have a time-series visualization, your insights might include period-over-period changes, anomalies, and forecasts. As you add more visualizations to your analysis, you generate more suggested insights.
+ **Custom insights**

  Custom insights enable you to create your own computation, using your own words to give context to the fields that appear in the widget. When you create a custom insight, you add it to the analysis, and then choose what type of calculation that you want to use. Then, you can add text and formatting to make it look how you want. You can also add more fields, calculations, and parameters.

You can add any combination of suggested and custom insights to your analysis, to create the decision-making environment that best serves your purposes.

**Topics**
+ [

# Adding suggested insights
](adding-suggested-insights.md)
+ [

# Adding custom insights to your analysis
](adding-insights.md)

# Adding suggested insights


Use the following procedure to add suggested insights to your analysis.

Before you begin, make sure that your dataset meets the criteria outlined in [Dataset requirements for using ML insights with Amazon Quick Sight](ml-data-set-requirements.md).

1. Begin with an analysis that has a few fields added to a visual. 

1. On the left, choose **Insights**. The **Insights** panel opens and displays a list of ready-to-use suggested insights. 

   Each visual also displays a small box on its top border to display how many insights are available for that visual. You can choose this box to open the **Insights** panel, and it opens to whatever view you most recently had open.

   Scroll down to preview more insights. 

   The insights that appear are controlled by the data type of the fields you choose to include in your visual. This list is generated each time you change your visual. If you make changes, check **Insights** to see what is new. To get a specific insight, see [Adding custom insights to your analysis](adding-insights.md).

1. (Optional) Open the context menu with more options for one of the insights. To do this, choose the ellipses on the top right of the insight (**…**).

   The options are different for each type of insight. The options that you can interact with include the following:
   + **Change the time series aggregation** – To year, quarter, month, week, day, hour, or minute.
   + **Analyze contributions to metrics** – Choose contributors and a time frame to analyze.
   + **Show all anomalies** – Browse anomalies in this time frame.
   + **Edit forecast** – Choose forecast length, prediction interval, and seasonality.
   + **Focus on** or **Exclude** – Zoom in or zoom out on your dimensional data.
   + **Show details** – View more information about a recent anomaly (outlier).
   + Provide feedback on the usefulness of the insight in your analysis.

1. Add a suggested insight to your analysis by choosing the plus sign (**\$1**) near the insight title.

1. (Optional) After you add an insight to your analysis, customize the narrative that you want it to display. To do this, choose the **v**-shaped on-visual menu, then choose **Customize narrative**. For more information, see [Creating autonarratives with Amazon Quick Sight](narratives-creating.md).

   If your insight is for anomalies (outliers), you can also change the settings for the anomaly detection job. To do this, choose **Configure anomaly**. For more information, see [Setting up ML-powered anomaly detection for outlier analysis](anomaly-detection-using.md).

1. (Optional) To remove the insight from your analysis, choose the **v**-shaped on-visual menu at the top right of the visual. Then choose **Delete**. 

# Adding custom insights to your analysis


If you don't want to use any of the suggested insights, you can create your own custom insight. Use the following procedure to create a custom computational insight.

1. Start with an existing analysis. On the top menu bar, choose **Add\$1**. Then choose **Add Insight**. 

   A container for the new insight is added to the analysis.

1. Do one of the following:
   + Choose the computation that you want to use from the list. As you choose each item, an example of that insight's output displays. When you find the one that you want to use, choose **Select**. 
   + Exit this screen and customize the insight manually. An unconfigured insight has a **Customize insight** button. Choose the button to open the **Configure narrative** screen. For more information on using the expression editor, see [Creating autonarratives with Amazon Quick Sight](narratives-creating.md). 

   Because you are initiating the creation of the insight, it's not based on an existing visual. When the insight is added to the analysis, it displays a note showing what kind of data it needs to complete your request. For example, it might ask for **1 dimension in Time**. In this case, you add a dimension to the **Time** field well. 

1. After you have the correct data, follow any remaining screen prompts to finish creating the custom insight.

1. (Optional) To remove the insight from your analysis, choose the **v**-shaped on-visual menu at the top right of the visual. Then choose **Delete**. 

# Creating autonarratives with Amazon Quick Sight
Autonarratives

An *autonarrative *is a natural-language summary widget that displays descriptive text instead of charts. You can embed these widgets throughout your analysis to highlight key insights and callouts. You don't have to sift through the visual, drilling down, comparing values, and rechecking ideas to extract a conclusion. You also don't have to try to understand what the data means, or discuss different interpretations with your colleagues. Instead, you can extrapolate the conclusion from the data, and display it in the analysis, stated plainly. A single interpretation can be shared by everyone.

Amazon Quick Sight automatically interprets the charts and tables in your dashboard and provides a number of suggested insights in natural language. The suggested insights that you can choose from are ready-made and come with words, calculations, and functions. But you can change them if you want to. You can also design your own. As the author of the dashboard, you have complete flexibility to customize the computations and language for your needs. You can use narratives to effectively tell the story of your data in plain language.

**Note**  
Narratives are separate from machine learning. They only use ML if you add forecast or anomaly (outlier) computations to them.

**Topics**
+ [

# Insights that include autonarratives
](auto-narratives.md)
+ [

# Use the narrative expression editor
](using-narratives-expression-editor-step-by-step.md)
+ [

# The expression editor workspace
](using-narratives-expression-editor-menus.md)
+ [

# Adding URLs
](using-narratives-expression-editor-urls.md)
+ [

# Working with autonarrative computations
](auto-narrative-computations.md)

# Insights that include autonarratives


When you are adding an insight, also known as an autonarrative, to your analysis, you can choose from the following templates. In the following list, they are defined by example. Each definition includes a list of the minimum required fields for the autonarrative to work. If you are using only the suggested insights on the **Insights** tab, choose the appropriate fields to get an insight to show up in the suggested insights list.

For more information on customizing autonarratives, see [Working with autonarrative computations](auto-narrative-computations.md).
+ **Bottom ranked** – For example, the bottom three states by sales revenue. Requires that you have at least one dimension in the **Categories** field well. 
+ **Bottom movers** – For example, the bottom three products sold, by sales revenue. Requires that you have at least one dimension in the **Time** field well and at least one dimension in the **Categories** field well. 
+ **Forecast** *(ML-powered insight) *– For example, "Total sales are forecasted to be \$158,613 for Jan 2016." Requires that you have at least one dimension in the **Time** field well. 
+ **Growth rate** – For example, "The 3-month compounded growth rate for sales is 22.23%." Requires that you have at least one dimension in the **Time** field well. 
+ **Maximum** – For example, "Highest month is Nov 2014 with sales of \$1112,326." Requires that you have at least one dimension in the **Time** field well. 
+ **Metric comparison** – For example, "Total sales for Dec 2014 is \$190,474, 10% higher than target of \$181,426." Requires that you have at least one dimension in the **Time** field well and at least two measures in the **Values** field well. 
+ **Minimum** – For example, "Lowest month is Feb 2011 with sales of \$14,810." Requires that you have at least one dimension in the **Time** field well. 
+ **Anomaly detection** *(ML-powered insight)* – For example, top three outliers and their contributing drivers for total sales on January 3, 2019. Requires that you have at least one dimension in the **Time** field well, at least one measure in the **Values** field well, and at least one dimension in the **Categories** field well. 
+ **Period over period** – For example, "Total sales for Nov 2014 increased by 44.39% (\$134,532) from \$177,793 to \$1112,326." Requires that you have at least one dimension in the **Time** field well. 
+ **Period to date** – For example, "Year-to-date sales for Nov 30, 2014 increased by 25.87% (\$1132,236) from \$1511,236 to \$1643,472." Requires that you have at least one dimension in the **Time** field well. 
+ **Top ranked** – For example, top three states by sales revenue. Requires that you have at least one dimension in the **Categories** field well. 
+ **Top movers** – For example, top products by sales revenue for November 2014. Requires that you have at least one dimension in the **Time** field well and at least one dimension in the **Categories** field well. 
+ **Total aggregation** – For example, "Total revenue is \$12,297,200." Requires that you have at least one dimension in the **Time** field well and at least one measure in the **Values** field well. 
+ **Unique values** – For example, "There are 793 unique values in `Customer_IDs`." Requires that you have at least one dimension in the **Categories** field well. 

# Use the narrative expression editor


The following walkthrough shows an example of how to customize a narrative. For this example, we use a period over period computation type.

1. Begin with an existing analysis. Add a **period over period** insight to it. The easiest way to do this is to choose the \$1 icon, then **Add insight**, then choose a type of insight from the list. To learn what type of computational insights you can add as autonarratives, see [Insights that include autonarratives](auto-narratives.md).

   After you choose a type of insight, choose **Select** to create the widget. To create an empty narrative, close this screen without choosing a template. To follow this example, choose **Period over period**.

   If you had a visual selected when you added the insight, the field wells have preconfigured fields for the date, metric, and category. These come from the visualization that you chose when you created the insight. You can customize the fields as needed.

   You can only customize a narrative for a new or existing insight (text-based) widget. You can't add one to an existing visual (chart based), because it's a different type of widget. 

1. Edit the narrative in the expressions editor by choosing the on-visual menu, then choosing **Customize narrative**.

   In this context, **Computations** are predefined calculations (period-over-period, period-to-date, growth rate, max, min, top movers, and so on) that you can reference in your template to describe your data. Currently, Amazon Quick Sight supports 13 different types of computations that you can add to your insight. In this example, **PeriodOverPeriod** is added by default because we chose the **Period Over Period** template from the suggested insights panel. 

1. Choose **Add computation** at bottom right to add a new computation, and then choose one from the list. For this walkthrough, choose **Growth rate**, and then choose **Next**.

1. Configure the computation by choosing the number of periods that you want to compute over. The default is four, and that works for our example. Optionally, you can change the name of the computation at the top of the screen. However, for our purposes, leave the name unchanged.
**Note**  
The computation names that you create are unique within the insight. You can reference multiple computations of the same type in your narrative template. For example, suppose that you have two metrics, sales revenue and units sold. You can create growth rate computations for each metric if they have different names.   
However, anomaly computations aren't compatible with any other computation type in the same widget. Anomaly detection must exist in an insight by itself. To use other computations in the same analysis, put them into insights separate from anomalies.

   To proceed, choose **Add**.

1. Expand **Computations** on the right. The computations that are part of the narrative display in the list. In this case, it's **PeriodOverPeriod** and **GrowthRate**. 

1. In the workspace, add the following text after the final period: **Compounded growth rate for the last**, then add a space.

1. Next, to add the computation leave your cursor after the space after the word **last**. On the right, under **GrowthRate**, choose the expression named **timePeriods** (click only once to add it). 

   Doing this inserts the expression **GrowthRate.timePeriods**, which is the number of periods you set in the configuration for **GrowthRate**. 

1. Complete the sentence with ** days is ** (a space before and afterwards), and add the expression **GrowthRate.compoundedGrowthRate.formattedValue**, followed by a period (`.`). Choose the expression from the list, rather than typing it in. However, you can edit the contents of the expression after you add it.  
![\[Expression editor with open expressions list.\]](http://docs.aws.amazon.com/quick/latest/userguide/images/narrative-add-expression.png)
**Note**  
The **formattedValue** expression returns a string that is formatted based on the formatting applied for the metric on the field. To perform metric math, use **value** instead, which returns the raw value as an integer or decimal.

1. Add a conditional statement and formatting. Place your cursor at the end of the template, after the `formattedValue` expression. Add a space if necessary. On the **Edit narrative** menu bar, choose **Insert code**, and then choose **Inline IF** from the list. An expression block opens.

1. With the expression block open, choose **GrowthRate**, **compoundedGrowthRate**, **value** from the expression list. Enter **>0** at the end of the expression. Choose **Save**. Don't move your cursor yet.

   A prompt appears for the conditional content; enter **better than expected\$1** Then select the text you just entered, and use the formatting toolbar at the top to turn it green and bold.

1. Add another expression block for the case when the growth rate wasn't that great by repeating the previous step. But this time, make it **<0** and enter the text **worse than expected**. Make it red instead of green. 

1. Choose **Save**. The customized narrative that we just created should look similar to the following.  
![\[Customized narrative.\]](http://docs.aws.amazon.com/quick/latest/userguide/images/narrative-example-result.png)

The expression editor provides you with a sophisticated tool to customize your narratives. You can also reference the parameters you create for your analysis or dashboard, and use a set of built-in functions for further customization.

**Tip**  
To create an empty narrative, add an insight using the **\$1** icon and then **Add insights**. But instead of choosing a template, simply close the screen.   
The best way to get started with customizing narratives is to use the existing templates to learn the syntax.

# The expression editor workspace


Use the expression editor to customize a narrative to best fit your business needs. The information below provides an overview of the expression editor workspace and lists all menu options that can be configured for your narrative. For a walkthrough that shows you how to create a custom narrative, see [Use the narrative expression editor](using-narratives-expression-editor-step-by-step.md).

On the right side of the screen, there's a list of items that you can add to the narrative:
+ **Computations** – Use this to choose from the computations that are available in this insight. You can expand this list.
+ **Parameters** – Use this to choose from the parameters that exist in your analysis. You can expand this list.
+ **Functions** – Use this to choose from functions that you can add to a narrative. You can expand this list.
+ **Add computation** – Use this button to create another computation. New computations appear in the **Computations** list, ready to add to the insight.

At the bottom of the narrative expression editor, there's a preview of the narrative that updates as you work. This area also shows an alert if you introduce an error into the narrative or if the narrative is empty. To see a preview of ML-powered insights like anomaly detection or forecasting, run your insight calculation at least once before customizing the narrative. 

Editing tools are located across the top of the screen. They offer the following options:
+ **Insert code** – You can insert the following code blocks from this menu:
  + **Expressions** – Add a free-form expression. 
  + **Inline IF** – Add an IF statement that displays inline with the existing block of text. 
  + **Inline FOR** – Add a FOR statement that displays inline with the existing block of text.
  + **Block IF** – Add an IF statement that displays in a separate block of text. 
  + **Block FOR** – Add a FOR statement that displays in a separate block of text. 

  The IF and FOR statements enable you to create content that is conditionally formatted. For example, you might add a **block IF** statement, then configure it to compare an integer to a value from a calculation. To do this, you use the following steps, also demonstrated in [Use the narrative expression editor](using-narratives-expression-editor-step-by-step.md):

  1. Open the calculations menu at right, and choose one of the blue highlighted items from one of the calculations. Doing this adds the item to the narrative.

  1. Click once on the item to open it.

  1. Enter the comparison that you want to make. The expression looks something like this: `PeriodOverPeriod.currentMetricValue.value>0`. 

  1. Save this expression in the pop-up editor, which prompts you for **Conditional content**. 

  1. Enter what you want to display in the insight, and format it as you want it to appear. Or if you prefer, you can add an image or a URL—or add a URL to an image.
+ **Paragraph** – This menu offers options for changes to the font size:
  + **H1 Large header**
  + H2 Header
  + H3 Small header
  + ¶1 Large paragraph
  + ¶2 Paragraph
  + ¶3 Small paragraph
+ **Font** – Use this menu tray to choose options for text formatting. These include bold, italic, underline, strikethrough, foreground color of the text (the letters themselves), and background color of the text. Choose the icon to turn on an option; choose it again to toggle the option off.
+ **Formatting** – Use this menu tray to choose options for paragraph formatting, including bulleted list, left justify, center, and right justify. Choose the icon to turn on an option, choose it again to toggle the option off.
+ **Image** – Use this icon add an image URL. The image displays in your insight, provided the link is accessible. You can resize images. To display an image based on a condition, put the image inside an IF block.
+ **URL** – Use this icon to add a static or dynamic URL. You can also add URLs to images. For example, you can add traffic light indicator images to an insight for an executive dashboard, with links to a new sheet for red, amber, and green conditions.

# Adding URLs


Using the **URL** button on the editing menu of the narrative expression editor, you can add static and dynamic URLs (hyperlinks) into a narrative. You can also use the following keyboard shortcuts: ⌘\$1⇧\$1L or Ctrl\$1⇧\$1L. 

A static URL is a link that doesn’t change; it always opens the same URL. A dynamic URL is a link that changes based on the expressions or parameters that you provide when you set it up. It's built with dynamically evaluated expressions or parameters. 

Following are of examples of when you might add a static link in your narrative: 
+ **In an IF statement, you might use the URL in the conditional content.** If you do and a metric fails to meet an expected value, your link might send the user to a wiki with a list of best practices to improve the metric. 
+ **You might use a static URL to create a link to another sheet in the same dashboard, by using the following steps:**

  1. Go to the sheet that you want to make the link to.

  1. Copy that sheet's URL.

  1. Return to the narrative editor and create a link using the URL that you just copied.

Following are examples of when you might add a dynamic link in your narrative: 
+ **To search a website with a query, by using the following steps.**

  1. Create a URL with the following link.

     ```
     https://google.com?q=<<formatDate(now(),'yyyy-MM-dd')>>
     ```

     This link sends a query to Google with search text that is the evaluated value of the following.

     ```
     formatDate(now(), 'yyyy-MM-dd')
     ```

     If the value of `now()` is `02/02/2020`, then the link on your narrative contains `https://google.com?q=2020-02-02`.
+ **To create a link that updates a parameter.** To do this, create or edit a link and set the URL to the current dashboard or analysis URL. Then add the expression that sets the parameter value to at the end, for example `#p.myParameter=12345`. 

  Suppose that the following is the dashboard link that you start with.

  ```
  https://us-east-1.quicksight.aws.amazon.com/sn/analyses/00000000-1111-2222-3333-44444444
  ```

  If you add a parameter value assignment to it, it looks like the following.

  ```
  https://us-east-1.quicksight.aws.amazon.com/sn/analyses/00000000-1111-2222-3333-44444444#p.myParameter=12345
  ```

  For more information on parameters in URLs, see [Using parameters in a URL](parameters-in-a-url.md).

# Working with autonarrative computations
Computations

Use this section to help you understand what functions are available to you when you are customizing an autonarrative. You only need to customize a narrative if you want to change or build on the default computation.

After you create an autonarrative, the expression editor opens. You can also activate the expression editor by choosing the on-visual menu, and then **Customize Narrative**. To add a computation while using the expression editor, choose **\$1 Add computation**.

You can use the following code expression to build your autonarrative. These are available from the list that's labeled **Insert code**. Code statements can display inline (in a sentence) or as a block (in a list).
+ Expression – Create your own code expression.
+ IF – An IF statement that includes an expression after evaluating a condition. 
+ FOR – A FOR statement that loops through values. 

You can use the following computations to build your autonarrative. You can use the expression editor without editing any syntax, but you can also customize it if you want to. To interact with the syntax, open the computational widget in the autonarrative expression editor.

**Topics**
+ [

# ML-powered anomaly detection for outliers
](anomaly-detection-function.md)
+ [

# Bottom movers computation
](bottom-movers-function.md)
+ [

# Bottom ranked computation
](bottom-ranked-function.md)
+ [

# ML-powered forecasting
](forecast-function.md)
+ [

# Growth rate computation
](growth-rate-function.md)
+ [

# Maximum computation
](maximum-function.md)
+ [

# Metric comparison computation
](metric-comparison-function.md)
+ [

# Minimum computation
](minimum-function.md)
+ [

# Period over period computation
](period-over-period-function.md)
+ [

# Period to date computation
](period-to-date-function.md)
+ [

# Top movers computation
](top-movers-function.md)
+ [

# Top ranked computation
](top-ranked-function.md)
+ [

# Total aggregation computation
](total-aggregation-function.md)
+ [

# Unique values computation
](unique-values-function.md)

# ML-powered anomaly detection for outliers
Anomaly detection for outliers

The ML-powered anomaly detection computation searches your data for outliers. For example, you can detect the top three outliers for total sales on January 3, 2019. If you enable contribution analysis, you can also detect the key drivers for each outlier. 

To use this function, you need at least one dimension in the **Time** field well, at least one measure in the **Values** field well, and at least one dimension in the **Categories** field well. The configuration screen provides an option to analyze the contribution of other fields as key drivers, even if those fields aren't in the field wells.

For more information, see [Detecting outliers with ML-powered anomaly detection](anomaly-detection.md).

**Note**  
You can't add ML-powered anomaly detection to another computation, and you can't add another computation to an anomaly detection.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name that you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. You can use items displayed in **`bold monospace font`** following in the narrative. 
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `categoryFields` – From the **Categories** field well.
  + `name` – The formatted display name of the field.
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `itemsCount` – The number of items included in this computation.
+ `items` – Anomalous items.
  + `timeValue` – The values in the date dimension.
    + `value` – The date/time field at the point of the anomaly (outlier).
    + `formattedValue` – The formatted value in the date/time field at the point of the anomaly.
  + `categoryName` – The actual name of the category (cat1, cat2, and so on).
  + `direction` – The direction on the x-axis or y-axis that's identified as anomalous: `HIGH` or `LOW`. `HIGH` means "higher than expected." `LOW` means "lower than expected." 

    When iterating on items, `AnomalyDetection.items[index].direction` can contain either `HIGH` or `LOW`. For example, `AnomalyDetection.items[index].direction='HIGH'` or `AnomalyDetection.items[index].direction=LOW`. `AnomalyDetection.direction` can have an empty string for `ALL`. An example is `AnomalyDetection.direction=''`. 
  + `actualValue` – The metric's actual value at the point of the anomaly or outlier.
    + `value` – The raw value.
    + `formattedValue` – The value formatted by the metric field.
    + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
  + `expectedValue` – The metric's expected value at the point of the anomaly (outlier).
    + `value` – The raw value.
    + `formattedValue` – The value formatted by the metric field.
    + `formattedAbsoluteValue` – The absolute value formatted by the metric field.

# Bottom movers computation


The bottom movers computation counts the requested number of categories by date that rank in the bottom of the autonarrative's dataset. For example, you can create a computation to find the bottom three products sold, by sales revenue.

To use this function, at least one dimension in the **Time** field well and at least one dimension in the **Categories** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Date*   
The date dimension that you want to rank.

*Category*   
The category dimension that you want to rank.

*Value*   
The aggregated measure that the computation is based on.

*Number of movers*   
The number of ranked results that you want to display.

*Order by*   
The order that you want to use, percent difference or absolute difference.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 

**Note**  
These are the same output parameters as the ones that are returned by the top movers computation.
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `categoryField` – From the **Categories** field well.
  + `name` – The formatted display name of the field.
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `startTimeValue` – The value in the date dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.
+ `endTimeValue` – The value in the date dimension.
  + `value` – The raw value.
  + `formattedValue` – The absolute value formatted by the datetime field.
+ `itemsCount` – The number of items included in this computation.
+ `items`: Bottom moving items.
  + `categoryField` – The category field.
    + `value` – The value (contents) of the category field.
    + `formattedValue` – The formatted value (contents) of the category field. If the field is null, this displays '`NULL`'. If the field is empty, it displays '`(empty)`'.
  + `currentMetricValue` – The current value for the metric field.
    + `value` – The raw value.
    + `formattedValue` – The value formatted by the metric field
    + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
  + `previousMetricValue` – The previous value for the metric field.
    + `value` – The raw value.
    + `formattedValue` – The value formatted by the metric field
    + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
  + `percentDifference` – The percent difference between the current and previous values of the metric field.
    + `value` – The raw value of the calculation of the percent difference.
    + `formattedValue` – The formatted value of the percent difference (for example, -42%).
    + `formattedAbsoluteValue` – The formatted absolute value of the percent difference (for example, 42%).
  + `absoluteDifference` – The absolute difference between the current and previous values of the metric field.
    + `value` – The raw value of the calculation of the absolute difference.
    + `formattedValue` – The absolute difference formatted by the settings in the metric field's format preferences.
    + `formattedAbsoluteValue` – The absolute value of the difference formatted by the metric field.

# Bottom ranked computation


The bottom ranked computation calculates the requested number of categories by value that rank in the bottom of the autonarrative's dataset. For example, you can create a computation to find the bottom three states by sales revenue.

To use this function, you need at least one dimension in the **Categories** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Category*   
The category dimension that you want to rank.

*Value*   
The aggregated measure that the computation is based on.

*Number of results*   
The number of ranked results that you want to display.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 

**Note**  
These are the same output parameters as the ones that are returned by the top ranked computation.
+ `categoryField` – From the **Categories** field well.
  + `name` – The formatted display name of the field.
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `itemsCount` – The number of items included in this computation.
+ `items`: Bottom ranked items.
  + `categoryField` – The category field.
    + `value` – The value (contents) of the category field.
    + `formattedValue` – The formatted value (contents) of the category field. If the field is null, this displays '`NULL`'. If the field is empty, it displays '`(empty)`'.
  + `metricValue` – The metric field.
    + `value` – The raw value.
    + `formattedValue` – The value formatted by the metric field.
    + `formattedAbsoluteValue` – The absolute value formatted by the metric field.

## Example


The following screenshot shows the default configuration for the bottom-ranked computation.

![\[Default configuration for the bottom-ranked computation.\]](http://docs.aws.amazon.com/quick/latest/userguide/images/bottom-ranked-computation.png)


# ML-powered forecasting
Forecasting

The ML-powered forecast computation forecasts future metrics based on patterns of previous metrics by seasonality. For example, you can create a computation to forecast total revenue for the next six months.

To use this function, you need at least one dimension in the **Time** field well. 

For more information about working with forecasts, see [Forecasting and creating what-if scenarios with Amazon Quick Sight](forecasts-and-whatifs.md).

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Date*   
The date dimension that you want to rank.

*Value*   
The aggregated measure that the computation is based on.

*Periods forward*   
The number of time periods in the future that you want to forecast. Ranges from 1 to 1,000.

*Periods backward*   
The number of time periods in the past that you want to base your forecast on. Ranges from 0 to 1,000.

*Seasonality*   
The number of seasons included in the calendar year. The default setting, **automatic** detects this for you. Ranges from 1 to 180.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `metricValue` – The value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `timeValue` – The value in the date dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the date field.
+ `relativePeriodsToForecast` – The relative number of periods between latest datetime record and last forecast record.

# Growth rate computation


The growth rate computation compares values over time periods. For example, you can create a computation to find the three-month compounded growth rate for sales, expressed as a percentage.

To use this function, you need at least one dimension in the **Time** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Date*   
The date dimension that you want to rank.

*Value*   
The aggregated measure that the computation is based on.

*Number of periods*   
The number of time periods in the future that you want to use to compute the growth rate.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `previousMetricValue` – The previous value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `previousTimeValue` – The previous value in the datetime dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.
+ `compoundedGrowthRate` – The percent difference between the current and previous values of the metric field.
  + `value` – The raw value of the calculation of the percent difference.
  + `formattedValue` – The formatted value of the percent difference (for example, -42%).
  + `formattedAbsoluteValue` – The formatted absolute value of the percent difference (for example, 42%).
+ `absoluteDifference` – The absolute difference between the current and previous values of the metric field.
  + `value` – The raw value of the calculation of the absolute difference.
  + `formattedValue` – The absolute difference formatted by the settings in the metric field's format preferences.
  + `formattedAbsoluteValue` – The absolute value of the difference formatted by the metric field.

# Maximum computation


The maximum computation finds the maximum dimension by value. For example, you can create a computation to find the month with the highest revenue. 

To use this function, you need at least one dimension in the **Time** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Date*   
The date dimension that you want to rank.

*Value*   
The aggregated measure that the computation is based on.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 

**Note**  
These are the same output parameters as the ones that are returned by the minimum computation.
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `metricValue` – The value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `timeValue` – The value in the datetime dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.

# Metric comparison computation


The metric comparison computation compares values in different measures. For example, you can create a computation to compare two values, such as actual sales compared to sales goals. 

To use this function, you need at least one dimension in the **Time** field well and at least two measures in the **Values** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Date*   
The date dimension that you want to rank.

*Value*   
The aggregated measure that the computation is based on.

*Target value*   
The field that you want to compare to the value.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `fromMetricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `fromMetricValue` – The value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `toMetricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `toMetricValue` – The current value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `timeValue` – The value in the datetime dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.
+ `percentDifference` – The percent difference between the current and previous values of the metric field.
  + `value` – The raw value of the calculation of the percent difference.
  + `formattedValue` – The formatted value of the percent difference (for example, -42%).
  + `formattedAbsoluteValue` – The formatted absolute value of the percent difference (for example, 42%).
+ `absoluteDifference` – The absolute difference between the current and previous values of the metric field.
  + `value` – The raw value of the calculation of the absolute difference.
  + `formattedValue` – The absolute difference formatted by the settings in the metric field's format preferences.
  + `formattedAbsoluteValue` – The absolute value of the difference formatted by the metric field.

# Minimum computation


The minimum computation finds the minimum dimension by value. For example, you can create a computation to find the month with the lowest revenue. 

To use this function, you need at least one dimension in the **Time** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Date*   
The date dimension that you want to rank.

*Value*   
The aggregated measure that the computation is based on.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 

**Note**  
These are the same output parameters as the ones that are returned by the maximum computation.
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `metricValue` – The value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `timeValue` – The value in the datetime dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.

# Period over period computation


The period over period computation compares values from two different time periods. For example, you can create a computation to find out how much sales increased or decreased since the previous time period. 

To use this function, you need at least one dimension in the **Time** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Date*   
The date dimension that you want to rank. 

*Value*   
The aggregated measure that the computation is based on. 

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `previousMetricValue` – The previous value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `previousTimeValue` – The previous value in the datetime dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.
+ `currentMetricValue` – The current value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `currentTimeValue` – The current value in the datetime dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.
+ `percentDifference` – The percent difference between the current and previous values of the metric field.
  + `value` – The raw value of the calculation of the percent difference.
  + `formattedValue` – The formatted value of the percent difference (for example, -42%).
  + `formattedAbsoluteValue` – The formatted absolute value of the percent difference (for example, 42%).
+ `absoluteDifference` – The absolute difference between the current and previous values of the metric field.
  + `value` – The raw value of the calculation of the absolute difference.
  + `formattedValue` – The absolute difference formatted by the settings in the metric field's format preferences.
  + `formattedAbsoluteValue` – The absolute value of the difference formatted by the metric field.

## Example


**To create a Period over period computation**

1. In the analysis that you want to change, choose **Add insight**.

1. For **Computation type**, choose **Period over period**, and then choose **Select**.

1. In the new insight that you created, add the time dimension and value dimension fields that you want to compare. In the screenshot below, `Order Date` and `Sales (Sum)` are added to the insight. With these two fields selected, Quick Sight shows the year to date sales of the latest month and the percentage difference compared with the previous month.  
![\[alt text not found\]](http://docs.aws.amazon.com/quick/latest/userguide/images/periodOverPeriod1.png)

1. (Optional) To further customize the insight, open the on-visual menu and choose **Customize narrative**. In the **Edit narative** window that appears, drag and drop the fields that you need from the **Computations** list, and then choose **Save**.

# Period to date computation


The period to date computation evaluates values for a specified period to date. For example, you can create a computation to find out how much you've earned in year-to-date sales. 

To use this function, you need at least one dimension in the **Time** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Date*   
The date dimension that you want to rank. 

*Value*   
The aggregated measure that the computation is based on. 

*Time granularity*   
The date granularity that you want to use for the computation, for example year to date.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 
+ `timeField` – From the **Time** field well. 
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `metricField` – From the **Values** field well. 
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `previousMetricValue` – The previous value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `previousTimeValue` – The previous value in the datetime dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.
+ `currentMetricValue` – The current value in the metric dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
+ `currentTimeValue` – The current value in the datetime dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.
+ `periodGranularity` – The period granularity for this computation (**MONTH**, **YEAR**, and so on).
+ `percentDifference` – The percent difference between the current and previous values of the metric field.
  + `value` – The raw value of the calculation of the percent difference.
  + `formattedValue` – The formatted value of the percent difference (for example, -42%).
  + `formattedAbsoluteValue` – The formatted absolute value of the percent difference (for example, 42%).
+ `absoluteDifference` – The absolute difference between the current and previous values of the metric field.
  + `value` – The raw value of the calculation of the absolute difference.
  + `formattedValue` – The absolute difference formatted by the settings in the metric field's format preferences.
  + `formattedAbsoluteValue` – The absolute value of the difference formatted by the metric field.

## Example


**To create a Period to date computation**

1. In the analysis that you want to change, choose **Add insight**.

1. For **Computation type**, choose **Period to date**, and then choose **Select**.

1. In the new insight that you created, add the time dimenstion and value dimension fields that you want to compare. In the screenshot below, `Order Date` and `Sales (Sum)` are added to the insight. With these two fields selected, Quick Sight shows the year to date sales of the latest month and the percentage difference compared with the previous month.  
![\[alt text not found\]](http://docs.aws.amazon.com/quick/latest/userguide/images/periodOverPeriod1.png)

1. (Optional) To further customize the insight, open the on-visual menu and choose **Customize narrative**. In the **Edit narative** window that appears, drag and drop the fields that you need from the **Computations** list, and then choose **Save**.

# Top movers computation


The top movers computation counts the requested number of categories by date that rank in the top of the autonarrative's dataset. For example, you can create a computation to find the top products by sales revenue for a time period.

To use this function, you need at least one dimension in the **Time** field well and at least one dimension in the **Categories** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Category*   
The category dimension you want to rank. 

*Value*   
The aggregated measure that the computation is based on. 

*Number of results*   
The number of top ranking items you want to find.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 

**Note**  
These are the same output parameters as the ones that are returned by the bottom movers computation.
+ `timeField` – From the **Time** field well.
  + `name` – The formatted display name of the field.
  + `timeGranularity` – The time field granularity (**DAY**, **YEAR**, and so on).
+ `categoryField` – From the **Categories** field well.
  + `name` – The formatted display name of the field.
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `startTimeValue` – The value in the date dimension.
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the datetime field.
+ `endTimeValue` – The value in the date dimension.
  + `value` – The raw value.
  + `formattedValue` – The absolute value formatted by the datetime field.
+ `itemsCount` – The number of items included in this computation.
+ `items`: Top moving items.
  + `categoryField` – The category field.
    + `value` – The value (contents) of the category field.
    + `formattedValue` – The formatted value (contents) of the category field. If the field is null, this displays '`NULL`'. If the field is empty, it displays '`(empty)`'.
  + `currentMetricValue` – The current value for the metric field.
    + `value` – The raw value.
    + `formattedValue` – The value formatted by the metric field.
    + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
  + `previousMetricValue` – The previous value for the metric field.
    + `value` – The raw value.
    + `formattedValue` – The value formatted by the metric field.
    + `formattedAbsoluteValue` – The absolute value formatted by the metric field.
  + `percentDifference` – The percent difference between the current and previous values of the metric field.
    + `value` – The raw value of the calculation of the percent difference.
    + `formattedValue` – The formatted value of the percent difference (for example, -42%).
    + `formattedAbsoluteValue` – The formatted absolute value of the percent difference (for example, 42%).
  + `absoluteDifference` – The absolute difference between the current and previous values of the metric field.
    + `value` – The raw value of the calculation of the absolute difference.
    + `formattedValue` – The absolute difference formatted by the settings in the metric field's format preferences.
    + `formattedAbsoluteValue` – The absolute value of the difference formatted by the metric field.

# Top ranked computation


The top ranked computation finds the top ranking dimensions by value. For example, you can create a computation to find the top three states by sales revenue. 

To use this function, you need at least one dimension in the **Categories** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Category*   
The category dimension that you want to rank. 

*Value*   
The aggregated measure that the computation is based on. 

*Number of results*   
The number of top ranking items that you want to find.

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 

**Note**  
These are the same output parameters as the ones that are returned by the bottom ranked computation.
+ `categoryField` – From the **Categories** field well.
  + `name` – The formatted display name of the field.
+ `metricField` – From the **Values** field well.
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `itemsCount` – The number of items included in this computation.
+ `items`: Top ranked items.
  + `categoryField` – The category field.
    + `value` – The value (contents) of the category field.
    + `formattedValue` – The formatted value (contents) of the category field. If the field is null, this displays '`NULL`'. If the field is empty, it displays '`(empty)`'.
  + `metricValue` – The metric field.
    + `value` – The raw value.
    + `formattedValue` – The value formatted by the metric field.
    + `formattedAbsoluteValue` – The absolute value formatted by the metric field.

# Total aggregation computation


The total aggregation computation creates a grand total of the value. For example, you can create a computation to find the total revenue. 

To use this function, you need at least one dimension in the **Time** field well and at least one measure in the **Values** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Value*   
The aggregated measure that the computation is based on. 

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 
+ `categoryField` – The category field. 
  + `name` – The display name of the category field.
+ `metricField` – From the **Values** field well. 
  + `name` – The formatted display name of the field.
  + `aggregationFunction` – The aggregation used for the metric (**SUM**, **AVG**, and so on).
+ `totalAggregate` – The total value of the metric aggregation. 
  + `value` – The raw value.
  + `formattedValue` – The value formatted by the metric field.
  + `formattedAbsoluteValue` – The absolute value formatted by the metric field.

# Unique values computation


The unique values computation counts the unique values in a category field. For example, you can create a computation to count the number of unique values in a dimension, such as how many customers you have

To use this function, you need at least one dimension in the **Categories** field well. 

## Parameters


*name*   
A unique descriptive name that you assign or change. A name is assigned if you don't create your own. You can edit this later.

*Category*   
The category dimension that you want to rank. 

## Computation outputs


Each function generates a set of output parameters. You can add these outputs to the autonarrative to customize what it displays. You can also add your own custom text. 

To locate the output parameters, open the **Computations** tab on the right, and locate the computation that you want to use. The names of the computations come from the name you provide when you create the insight. Choose the output parameter by clicking on it only once. If you click twice, you add the same output twice. Items displayed in **bold** can be used in the narrative. 
+ `categoryField` – The category field. 
  + `name` – The display name of the category field.
+ `uniqueGroupValuesCount` – The number of unique values included in this computation. 

# Detecting outliers with ML-powered anomaly detection
Detecting outliers

Amazon Quick Sight uses proven Amazon technology to continuously run ML-powered anomaly detection across millions of metrics to discover hidden trends and outliers in your data. This tool allows you to get deep insights that are often buried in the aggregates and not scalable with manual analysis. With ML-powered anomaly detection, you can find outliers in your data without the need for manual analysis, custom development, or ML domain expertise. 

Amazon Quick Sight notifies you in your visuals if it detects that you can analyze an anomaly or do some forecasting on your data. 

Anomaly detection is not available in the `eu-central-2` Europe (Zurich) region.

**Important**  
ML-powered anomaly detection is a compute-intense task. Before you start using it, you can get an idea of costs by analyzing the amount of data that you want to use. We offer a tiered pricing model that is based on the number of metrics you process per month. 

**Topics**
+ [

# Concepts for anomaly or outlier detection
](anomaly-detection-outliers-and-key-drivers.md)
+ [

# Setting up ML-powered anomaly detection for outlier analysis
](anomaly-detection-using.md)
+ [

# Exploring outliers and key drivers with ML-powered anomaly detection and contribution analysis
](anomaly-exploring.md)

# Concepts for anomaly or outlier detection


Amazon Quick Sight uses the word *anomaly* to describe data points that fall outside an overall pattern of distribution. There are many other words for anomalies, which is a scientific term, including outliers, deviations, oddities, exceptions, irregularities, quirks, and many more. The term that you use might be based on the type of analysis you do, or the type of data you use, or even just the preference of your group. These outlying data points represent an entity—a person, place, thing, or time—which is exceptional in some way. 

Humans easily recognize patterns and spot things that aren't like the others. Our senses provide this information for us. If the pattern is simple, and there is only a little data, you can easily make a graph to highlight the outliers in your data. Some simple examples include the following:
+ A red balloon in a group of blue ones
+ A racehorse that is far ahead of the others
+ A kid who isn't paying attention during class
+ A day when online orders are up, but shipping is down
+ A person who got well, where others didn't

Some data points represent a significant event, and others represent a random occurrence. Analysis uncovers which data is worth investigating, based on what driving factors (key drivers) contributed to the event. Questions are essential to data analysis. Why did it happen? What's it related to? Did it happen only once or many times? What can you do to encourage or discourage more like it? 

Understanding how and why a variation exists, and whether there is a pattern in the variations, requires more thought. Without the assistance of machine learning, each person might come to a different conclusion, because they have different experience and information. Therefore, each person might make a slightly different business decision. If there is a lot of data or variables to consider, it can require an overwhelming amount of analysis. 

ML-powered anomaly detection identifies the causations and correlations to enable you to make data-driven decisions. You still have control over defining how you want the job to work on your data. You can specify your own parameters, and choose additional options, such as identifying key drivers in a contribution analysis. Or you can use the default settings. The following section walks you through the setup process, and provides explanations for the options available. 

# Setting up ML-powered anomaly detection for outlier analysis


Use procedures in the following sections to start detecting outliers, detecting anomalies, and identifying the key drivers that contribute to them.

**Topics**
+ [

# Viewing anomaly and forecast notifications
](anomaly-detection-adding-from-visuals.md)
+ [

# Adding an ML insight to detect outliers and key drivers
](anomaly-detection-adding-anomaly-insights.md)
+ [

# Using contribution analysis for key drivers
](anomaly-detection-adding-key-drivers.md)

# Viewing anomaly and forecast notifications


Amazon Quick Sight notifies you on a visual where it detects an anomaly, key drivers, or a forecasting opportunity. You can follow the prompts to set up anomaly detection or forecasting based on the data in that visual.

1. In an existing line chart, look for an insight notification in the menu on the visual widget. 

1. Choose the lightbulb icon to display the notification.

1. If you want more information about the ML insight, you can follow the screen prompts to add an ML insight.

# Adding an ML insight to detect outliers and key drivers


You can add an ML insight that detects *anomalies*, which are outliers that seem significant. To get started, you create for your insight a widget, also known as an *autonarrative*. As you configure your options, you can view a limited screenshot of your insight in the **Preview** pane at screen right.

In your insight widget, you can add up to five dimension fields that are not calculated fields. In the field wells, values for **Categories** represent the dimensional values that Amazon Quick Sight uses to split the metric. For example, let's say that you are analyzing revenue across all product categories and product SKUs. There are 10 product categories, each with 10 product SKUs. Amazon Quick Sight splits the metric by the 100 unique combinations and runs anomaly detection on each combination for the split.

The following procedure shows how to do this, and also how to add contribution analysis to detect the key drivers that are causing each anomaly. You can add contribution analysis later, as described in [Using contribution analysis for key drivers](anomaly-detection-adding-key-drivers.md).

**To set up outlier analysis, including key drivers**

1. Open your analysis and in the toolbar, choose **Insights**, then **Add**. From the list, choose **Anomaly detection** and **Select**.

1. Follow the screen prompt on the new widget, which tells you to choose fields for the insight. Add at least one date, one measure, and one dimension. 

1. Choose **Get started** on the widget. The configuration screen appears.

1. Under **Compute options**, choose values for the following options.

   1. For **Combinations to be analysed**, choose one of the following options:

      1. **Hierarchical**

         Choose this option if you want to analyze the fields hierarchically. For example, if you chose a date (T), a measure (N), and three dimension categories (C1, C2, and C3), Quick Sight analyses the fields hierarchically, as shown following.

         ```
         T-N, T-C1-N, T-C1-C2-N, T-C1-C2-C3-N
         ```

      1. **Exact**

         Choose this option if you want to analyze only the exact combination of fields in the Category field well, as they are listed. For example, if you chose a date (T), a measure (N), and three dimension categories (C1, C2, and C3), Quick Sight analyses only the exact combination of category fields in the order they are listed, as shown following.

         ```
         T-C1-C2-C3-N
         ```

      1. **All**

         Choose this option if you want to analyze all field combinations in the Category field well. For example, if you chose a date (T), a measure (N), and three dimension categories (C1, C2, and C3), Quick Sight analyses all combinations of fields, as shown following.

         ```
         T-N, T-C1-N, T-C1-C2-N, T-C1-C2-C3-N, T-C1-C3-N, T-C2-N, T-C2-C3-N, T-C3-N
         ```

      If you chose a date and a measure only, Quick Sight analyses the fields by date and then by measure.

      In the **Fields to be analyzed** section, you can see a list of fields from the field wells for reference.

   1. For **Name**, enter a descriptive alphanumeric name with no spaces, or choose the default value. This provides a name for the computation.

      If you plan on editing the narrative that automatically displays on the widget, you can use the name to identify this widget's calculation. Customize the name if you plan to edit the autonarrative and if you have other similar calculations in your analysis.

1. In the **Display options** section, choose the following options to customize what is displayed in your insight widget. You can still explore all your results, no matter what you display.

   1. **Maximum number of anomalies to show** – The number of outliers you want to display in the narrative widget. 

   1. **Severity** – The minimum level of severity for anomalies that you want to display in the insight widget.

      A *level of severity* is a range of anomaly scores that is characterized by the lowest actual anomaly score included in the range. All anomalies that score higher are included in the range. If you set severity to **Low**, the insight displays all of the anomalies that rank between low and very high. If you set the severity to **Very high**, the insight displays only the anomalies that have the highest anomaly scores.

      You can use the following options:
      + **Very high** 
      + **High and above** 
      + **Medium and above** 
      + **Low and above** 

   1. **Direction** – The direction on the x-axis or y-axis that you want to identify as anomalous. You can choose from the following:
      + **Higher than expected** to identify higher values as anomalies.
      + **Lower than expected** to identify lower values as anomalies. 
      + **[ALL]** to identify all anomalous values, high and low (default setting).

   1. **Delta** – Enter a custom value to use to identify anomalies. Any amount higher than the threshold value counts as an anomaly. The values here change how the insight works in your analysis. In this section, you can set the following:
      + **Absolute value** – The actual value to use. For example, suppose this is 48. Amazon Quick Sight then identifies values as anomalous when the difference between a value and the expected value is greater than 48. 
      + **Percentage** – The percentage threshold to use. For example, suppose this is 12.5%. Amazon Quick Sight then identifies values as anomalous when the difference between a value and the expected value is greater than 12.5%.

   1. **Sort by** – Choose a sort method for your results. Some methods are based on the anomaly score that Amazon Quick Sight generates. Amazon Quick Sight gives higher scores to data points that look anomalous. You can use any of the following options: 
      + **Weighted anomaly score** – The anomaly score multiplied by the log of the absolute value of the difference between the actual value and the expected value. This score is always a positive number. 
      + **Anomaly score** – The actual anomaly score assigned to this data point.
      + **Weighted difference from expected value** – The anomaly score multiplied by the difference between the actual value and the expected value (default).
      + **Difference from expected value** – The actual difference between the actual value and the expected value (that is, actual−expected).
      + **Actual value** – The actual value with no formula applied.

1. In the **Schedule options** section, set the schedule for automatically running the insight recalculation. The schedule runs only for published dashboards. In the analysis, you can run it manually as needed. Scheduling includes the following settings:
   + **Occurrence** – How often that you want the recalculation to run: every hour, every day, every week, or every month.
   + **Start schedule on** – The date and time to start running this schedule.
   + **Timezone** – The time zone that the schedule runs in. To view a list, delete the current entry. 

1. In the **Top contributors** section, set Amazon Quick Sight to analyze the key drivers when an outlier (anomaly) is detected.

   For example, Amazon Quick Sight can show the top customers that contributed to a spike in sales in the US for home improvement products. You can add up to four dimensions from your dataset. These include dimensions that you didn't add to the field wells of this insight widget.

   For a list of dimensions available for contribution analysis, choose **Select fields**.

1. Choose **Save** to confirm your choices. Choose **Cancel** to exit without saving.

1. From the insight widget, choose **Run now** to run the anomaly detection and view your insight.

The amount of time that anomaly detecton takes to complete varies depending on how many unique data points you are analyzing. The process can take a few minutes for a minimum number of points, or it can take many hours.

While it's running in the background, you can do other work in your analysis. Make sure to wait for it to complete before you change the configuration, edit the narrative, or open the **Explore anomalies** page for this insight.

The insight widget needs to run at least once before you can see results. If you think the status might be out of date, you can refresh the page. The insight can have the following states.


| Appears on the Page | Status | 
| --- | --- | 
| Run now button | The job has not yet started. | 
| Message about Analyzing for anomalies | The job is currently running. | 
| Narrative about the detected anomalies (outliers)  | The job has run successfully. The message says when this widget's calculation was last updated. | 
| Alert icon with an exclamation point (\$1)  | This icon indicates there was an error during the last run. If the narrative also displays, you can still use Explore anomalies to use data from the previous successful run.  | 

# Using contribution analysis for key drivers


Amazon Quick Sight can identify the dimensions (categories) that contribute to outliers in measures (metrics) between two points in time. The key driver that contributes to an outlier helps you to answer the question: What happened to cause this anomaly? 

If you are already using anomaly detection without contribution analysis, you can enable the existing ML insight to find key drivers. Use the following procedure to add contribution analysis and identify the key drivers behind outliers. Your insight for anomaly detection needs to include a time field and at least one aggregated metric (SUM, AVERAGE, or COUNT). You can include multiple categories (dimension fields) if you wish, but you can also run contribution analysis without specifying any category or dimension field.

You can also use this procedure to change or remove fields as key drivers in your anomaly detection.

**To add contribution analysis to identify key drivers**

1. Open your analysis and locate an existing ML insight for anomaly detection. Select the insight widget to highlight it.

1. Choose **Menu Options** (**…**) from the menu on the visual.

1. Choose **Configure anomaly** to edit the settings.

1. The **Contribution analysis (optional)** setting allows Amazon Quick Sight to analyze the key drivers when an outlier (anomaly) is detected. For example, Amazon Quick Sight can show you the top customers that contributed to a spike in sales in the US for home improvement products. You can add up to four dimensions from your dataset, including dimensions that you didn't add to the field wells of this insight widget.

   To view a list of dimensions available for contribution analysis, choose **Select fields**.

   If you want to change the fields you're using as key drivers, change the fields that are enabled in this list. If you disable all of them, Quick Sight won't perform any contribution analysis in this insight.

1. To save your changes, scroll to the bottom of the configuration options, and choose **Save**. To exit without saving, choose **Cancel**. To completely remove these settings, choose **Delete**.

# Exploring outliers and key drivers with ML-powered anomaly detection and contribution analysis
Exploring outliers and key drivers

You can interactively explore the anomalies (also known as outliers) in your analysis, along with the contributors (key drivers). The analysis is available for you to explore after the ML-powered anomaly detection runs. The changes you make in this screen aren't saved when you go back to the analysis.

To begin, choose **Explore anomalies** in the insight. The following screenshot shows the anomalies screen as it appears when you first open it. In this example, contributors analysis is set up and shows two key drivers.

![\[Anomalies analysis with contributors shown.\]](http://docs.aws.amazon.com/quick/latest/userguide/images/anomaly-exploration-v2.png)


The sections of the screen include the following, from top left to bottom right:
+ **Contributors** displays key drivers. To see this section, you need to have contributors set up in your anomaly configuration. 
+ **Controls** contains settings for anomaly exploration.
+ **Number of anomalies** displays outliers detected over time. You can hide or show this chart section.
+ **Your field names** for category or dimension fields act as titles for charts that show anomalies for each category or dimension. 

The following sections provide detailed information for each aspect of exploring anomalies.

**Topics**
+ [

# Exploring contributors (key drivers)
](exploring-anomalies-key-drivers.md)
+ [

# Setting controls for anomaly detection
](exploring-anomalies-controls.md)
+ [

# Showing and hiding anomalies by date
](exploring-anomalies-by-date.md)
+ [

# Exploring anomalies per category or dimension
](exploring-anomalies-per-category-or-dimension.md)

# Exploring contributors (key drivers)


If your anomaly insight is set up to detect key drivers, Quick Sight runs the contribution analysis to determine which categories (dimensions) are influencing the outliers. The **Contributors** section appears on the left. 

**Contributors** contains the following sections:
+ **Narrative** – At top left, a summary describes any changes in the metrics.
+ **Top contributors configuration** – Choose **Configure** to change the contributors and the date range to use in this section.
+ **Sort by** – Sets the sort applied to the results that appear below. You can choose from the following:
  + **Absolute difference** 
  + **Contribution percentage** (default) 
  + **Deviation from expected** 
  + **Percentage difference** 
+ **Top contributor results** – Displays the results of the top contributor analysis for the point in time selected on the timeline at right. 

  Contribution analysis identifies up to four of the top contributing factors or key drivers of an anomaly. For example, Amazon Quick Sight can show you the top customers that contributed to a spike in sales in the US for health products. This panel appears only if you choose to include fields in contribution analysis when you configure the anomaly. 

  If you don't see this panel and you want to display it, you can turn it on. To do so, go to the analysis, choose anomaly configuration from the insight's menu, and choose up to four fields to analyze for contributions. If you make changes in the sheet controls that exclude the contributing drivers, the **Contributions** panel closes.

# Setting controls for anomaly detection


You can find the settings for anomaly detection in the **Controls** section of the screen. You can open and close this section by clicking the word **Controls**.

The settings include the following:
+ **Controls** – The current settings appear at the top of the workspace. You can expand this section by choosing the double arrow icon on the right side. The following settings are available for exploring outliers generated by ML-powered anomaly detection:
  + **Severity** – Sets how sensitive your detector is to detected anomalies (outliers). You should expect to see more anomalies with the threshold set to **Low and above**, and fewer anomalies when the threshold is set to **High and above**. This sensitivity is determined based on standard deviations of the anomaly score generated by the RCF algorithm. The default is **Medium and above**.
  + **Direction** – The direction on the x-axis or y-axis that you want to identify as anomalous. The default is [ALL]. You can choose the following:
    + Set to **Higher than expected** to identify higher values as anomalies. 
    + Set to **Lower than expected** to identify lower values as anomalies. 
    + Set to **[ALL]** to identify all anomalous values, both high and low. 
  + **Minimum Delta - absolute value** – Enter a custom value to use to as the absolute threshold to identify anomalies. Any amount higher than this value counts as an anomaly. 
  + **Minimum Delta - percentage** – Enter a custom value to use to as the percentage threshold to identify anomalies. Any amount higher than this value counts as an anomaly. 
  + **Sort by** – Choose the method that you want to apply to sorting anomalies. These are listed in preferred order on the screen. View the following list for a description of each method.
    + **Weighted anomaly score** – The anomaly score multiplied by the log of the absolute value of the difference between the actual value and the expected value. This score is always a positive number.
    + **Anomaly score** – The actual anomaly score assigned to this data point.
    + **Weighted difference from expected value** – (Default) The anomaly score multiplied by the difference between the actual value and the expected value.
    + **Difference from expected value** – The actual difference between the actual value and the expected value (actual−expected).
    + **Actual value** – The actual value with no formula applied.
  + **Categories** – One or more settings can appear at the end of the other settings. There is one for each category field that you added to the category field well. You can use category settings to limit the data that displays in the screen. 

# Showing and hiding anomalies by date


The **Number of anomalies** chart shows outliers detected over time. If you don't see this chart, you can display it by choosing **SHOW ANOMALIES BY DATE**. 

This chart shows anomalies (outliers) for the most recent data point in the time series. When expanded, it displays the following components:
+ **Anomalies** – The middle of the screen displays the anomalies for the most recent data point in the time series. One or more graphs appear with a chart showing variations in a metric over time. To use this graph, select a point along the timeline. The currently selected point in time is highlighted in the graph, and includes a menu offering you the option to analyze contributions to the current metric. You can also drag the cursor over the timeline without choosing a specific point to display the metric value for that point in time.
+ **Anomalies by date** – If you choose **SHOW ANOMALIES BY DATE**, another graph appears that shows how many significant anomalies there were for each time point. You can see details in this chart on each bar's context menu. 
+ **Timeline adjustment** – Each graph has a timeline adjustor tool below the dates, which you can use to compress, expand, or choose a period of time to view.

# Exploring anomalies per category or dimension


The main section of the **Explore anomalies** screen is locked to the lower right of the screen. It remains here no matter how many other sections of the screen are open. If multiple anomalies exist, you can scroll out to highlight them. The chart displays anomalies in color ranges and shows where they occur over a period of time. 

![\[Explore anomalies screen.\]](http://docs.aws.amazon.com/quick/latest/userguide/images/anomaly-exploration-1.png)


Each category or dimension has a separate chart that uses the field name as the chart title. Each chart contains the following components:
+ **Configure alerts** – If you are exploring anomalies from a dashboard, select this button to subscribe to alerts and contribution analysis (if configured). You can set up the alerts for the level of severity (medium, high, and so on). You can get the top five alerts for **Higher than expected**, **Lower than expected**, or ALL. Dashboard readers can configure alerts for themselves. If you open the **Explore Anomalies** page doesn't display this button if you opened the page from an analysis.
**Note**  
The ability to configure alerts is available only in published dashboards.
+ **Status** – Under the **Anomalies** header, the status label displays information on the last run. For example, you might see "Anomalies for Revenue on November 17, 2018." This label tells you how many metrics were processed and how long ago. You can choose the link to learn more about the details, such as how many metrics were ignored.

# Forecasting and creating what-if scenarios with Amazon Quick Sight
ML-powered forecasts and what-ifs

Using ML-powered forecasting, you can forecast your key business metrics with point-and-click simplicity. No machine learning expertise is required. The built-in ML algorithm in Amazon Quick Sight is designed to handle complex real-world scenarios. Amazon Quick Sight uses machine learning to help provide more reliable forecasts than available by traditional means.

For example, suppose that you are a business manager. Suppose that you want to forecast sales to see if you are going to meet your goal by the end of the year. Or, suppose that you expect a large deal to come through in two weeks and you want to know how it's going to affect your overall forecast. 

You can forecast your business revenue with multiple levels of seasonality (for example, sales with both weekly and quarterly trends). Amazon Quick Sight automatically excludes anomalies in the data (for example, a spike in sales due to price drop or promotion) from influencing the forecast. You also don't have to clean and reprep the data with missing values because Amazon Quick Sight automatically handles that. In addition, with ML-powered forecasting, you can perform interactive what-if analyses to determine the growth trajectory you need to meet business goals.

## Using forecasts and what-if scenarios


You can add a forecasting widget to your existing analysis, and publish it as a dashboard. To analyze what-if scenarios, use an analysis, not a dashboard. With ML-powered forecasting, Amazon Quick Sight enables you to forecast complex, real-world scenarios such as data with multiple seasonality. It automatically excludes outliers that it identifies and imputes missing values.

Use the following procedure to add a graphical forecast to your analysis, and explore what-if scenarios.

Although the following procedure is for graphical forecasting, you can also add a forecast as a narrative in an insight widget. To learn more, see [Creating autonarratives with Amazon Quick Sight](narratives-creating.md).

ML-powered forecasting is not compatible with [small multiples](small-multiples.md). To ensure accurate display of data and forecasts, avoid using small multiples in your visualizations.

**To add a graphical forecast to your analysis**

1. Create a visual that uses a single date field and up to three metrics (measures).

1. On the menu in the upper-right corner of the visual, choose the **Menu options** icon (the three dots), and then choose **Add forecast**.

   Quick Sight automatically analyzes the historical data using ML, and displays a graphical forecast for the next 14 periods. Forecast properties apply to all metrics in your visual. If you want individual forecasts for each metric, consider creating a separate visual for each metric and adding a forecast to each.  
![\[Image of a line-chart visual with three metrics forecasted.\]](http://docs.aws.amazon.com/quick/latest/userguide/images/forecast2.png)

1. On the **Forecast properties** panel at left, customize one or more of the following settings:
   + **Forecast length** – Set **Periods forward** to forecast, or set **Periods backward** to look for patterns to base the forecast on.
   + **Prediction interval** – Set the estimated range for the forecast. Doing this changes how wide the band of possibility is around the predicted line. 
   + **Seasonality** – Set the number of time periods involved in the predictable seasonal pattern of data. The range is 1–180, and the default setting is **Automatic**.
   + **Forecast boundaries** – Set a minimum and/or maximum forecast value to prevent forecast values from going above or below a specified value. For example, if your forecasting predicts the number of new hires the company will make in the next month to be in the negative numbers, you can set a forecast boundary minimum to zero. This stops the forecasted values from ever going below zero.

   To save your changes, choose **Apply**.

   If your forecast contains multiple metrics, you can isolate one of the forecasts by selecting anywhere inside the orange band. When you do this, the other forecasts disappear. Select the isolated forecast band again to have them reappear.

1. Analyze what-if scenarios by choosing a forecasted data point (in the orange band) on the chart, and then choosing **What-if analysis** from the context menu.

   The **What-if analysis** panel opens at left. Set the following options:
   + **Scenario** – Set a target for a date, or set a target for a time range.
   + **Dates** – If you are setting a target for a specific date, enter that date here. If you are using a time range, set the start and end dates.
   + **Target** – Set a target value for the metric.

   Amazon Quick Sight adjusts the forecast to meet the target. 
**Note**  
The **What-if analysis** option isn't available for multiple-metric forecasts. If you want to perform a what-if scenario on your forecast, your visual should contain only one metric.

1. Keep your changes by choosing **Apply**. To discard them, close the **What-if analysis** panel. 

   If you keep your changes, you see the new forecast adjusted for the target, alongside the original forecast without the what-if. 

   The what-if analysis is represented on the visual as a dot on the metric line. You can hover over the data points on the forecasting line to see the details. 

Here are other things you can do:
+ To interact with or remove a what-if analysis, choose the dot on the metric line. 
+ To create additional what-if scenarios, close the what-if analysis before choosing a new point on the line.

**Note**  
What-if analyses can exist inside an analysis only, not inside a dashboard.