CreateWhatIfAnalysis - Amazon Forecast


What-if analysis is a scenario modeling technique where you make a hypothetical change to a time series and compare the forecasts generated by these changes against the baseline, unchanged time series. It is important to remember that the purpose of a what-if analysis is to understand how a forecast can change given different modifications to the baseline time series.

For example, imagine you are a clothing retailer who is considering an end of season sale to clear space for new styles. After creating a baseline forecast, you can use a what-if analysis to investigate how different sales tactics might affect your goals.

You could create a scenario where everything is given a 25% markdown, and another where everything is given a fixed dollar markdown. You could create a scenario where the sale lasts for one week and another where the sale lasts for one month. With a what-if analysis, you can compare many different scenarios against each other.

Note that a what-if analysis is meant to display what the forecasting model has learned and how it will behave in the scenarios that you are evaluating. Do not blindly use the results of the what-if analysis to make business decisions. For instance, forecasts might not be accurate for novel scenarios where there is no reference available to determine whether a forecast is good.

The TimeSeriesSelector object defines the items that you want in the what-if analysis.


Your data must be in comma-separated values (CSV) format to create a what-if analysis.

Request Syntax

{ "ForecastArn": "string", "Tags": [ { "Key": "string", "Value": "string" } ], "TimeSeriesSelector": { "TimeSeriesIdentifiers": { "DataSource": { "S3Config": { "KMSKeyArn": "string", "Path": "string", "RoleArn": "string" } }, "Format": "string", "Schema": { "Attributes": [ { "AttributeName": "string", "AttributeType": "string" } ] } } }, "WhatIfAnalysisName": "string" }

Request Parameters

The request accepts the following data in JSON format.


The Amazon Resource Name (ARN) of the baseline forecast.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):forecast:.*:.*:.+

Required: Yes


A list of tags to apply to the what if forecast.

Type: Array of Tag objects

Array Members: Minimum number of 0 items. Maximum number of 200 items.

Required: No


Defines the set of time series that are used in the what-if analysis with a TimeSeriesIdentifiers object. What-if analyses are performed only for the time series in this object.

The TimeSeriesIdentifiers object needs the following information:

  • DataSource

  • Format

  • Schema

Type: TimeSeriesSelector object

Required: No


The name of the what-if analysis. Each name must be unique.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z][a-zA-Z0-9_]*

Required: Yes

Response Syntax

{ "WhatIfAnalysisArn": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.


The Amazon Resource Name (ARN) of the what-if analysis.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):forecast:.*:.*:.+



We can't process the request because it includes an invalid value or a value that exceeds the valid range.

HTTP Status Code: 400


The limit on the number of resources per account has been exceeded.

HTTP Status Code: 400


There is already a resource with this name. Try again with a different name.

HTTP Status Code: 400


The specified resource is in use.

HTTP Status Code: 400


We can't find a resource with that Amazon Resource Name (ARN). Check the ARN and try again.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: