

 Amazon Forecast is no longer available to new customers. Existing customers of Amazon Forecast can continue to use the service as normal. [Learn more"](https://aws.amazon.com/blogs/machine-learning/transition-your-amazon-forecast-usage-to-amazon-sagemaker-canvas/)

# CreateWhatIfAnalysis
<a name="API_CreateWhatIfAnalysis"></a>

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.

**Important**  
Amazon Forecast is no longer available to new customers. Existing customers of Amazon Forecast can continue to use the service as normal. [Learn more"](http://aws.amazon.com/blogs/machine-learning/transition-your-amazon-forecast-usage-to-amazon-sagemaker-canvas/) 

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](API_TimeSeriesSelector.md) object defines the items that you want in the what-if analysis.

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

## Request Syntax
<a name="API_CreateWhatIfAnalysis_RequestSyntax"></a>

```
{
   "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
<a name="API_CreateWhatIfAnalysis_RequestParameters"></a>

The request accepts the following data in JSON format.

 ** [ForecastArn](#API_CreateWhatIfAnalysis_RequestSyntax) **   <a name="forecast-CreateWhatIfAnalysis-request-ForecastArn"></a>
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

 ** [Tags](#API_CreateWhatIfAnalysis_RequestSyntax) **   <a name="forecast-CreateWhatIfAnalysis-request-Tags"></a>
A list of [tags](https://docs.aws.amazon.com/forecast/latest/dg/tagging-forecast-resources.html) to apply to the what if forecast.  
Type: Array of [Tag](API_Tag.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 200 items.  
Required: No

 ** [TimeSeriesSelector](#API_CreateWhatIfAnalysis_RequestSyntax) **   <a name="forecast-CreateWhatIfAnalysis-request-TimeSeriesSelector"></a>
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](API_TimeSeriesSelector.md) object  
Required: No

 ** [WhatIfAnalysisName](#API_CreateWhatIfAnalysis_RequestSyntax) **   <a name="forecast-CreateWhatIfAnalysis-request-WhatIfAnalysisName"></a>
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
<a name="API_CreateWhatIfAnalysis_ResponseSyntax"></a>

```
{
   "WhatIfAnalysisArn": "string"
}
```

## Response Elements
<a name="API_CreateWhatIfAnalysis_ResponseElements"></a>

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

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

 ** [WhatIfAnalysisArn](#API_CreateWhatIfAnalysis_ResponseSyntax) **   <a name="forecast-CreateWhatIfAnalysis-response-WhatIfAnalysisArn"></a>
The Amazon Resource Name (ARN) of the what-if analysis.  
Type: String  
Length Constraints: Maximum length of 256.  
Pattern: `arn:([a-z\d-]+):forecast:.*:.*:.+` 

## Errors
<a name="API_CreateWhatIfAnalysis_Errors"></a>

 ** InvalidInputException **   
We can't process the request because it includes an invalid value or a value that exceeds the valid range.  
HTTP Status Code: 400

 ** LimitExceededException **   
The limit on the number of resources per account has been exceeded.  
HTTP Status Code: 400

 ** ResourceAlreadyExistsException **   
There is already a resource with this name. Try again with a different name.  
HTTP Status Code: 400

 ** ResourceInUseException **   
The specified resource is in use.  
HTTP Status Code: 400

 ** ResourceNotFoundException **   
We can't find a resource with that Amazon Resource Name (ARN). Check the ARN and try again.  
HTTP Status Code: 400

## See Also
<a name="API_CreateWhatIfAnalysis_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/forecast-2018-06-26/CreateWhatIfAnalysis) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/forecast-2018-06-26/CreateWhatIfAnalysis) 