Dynamics 365 Demand Forecasting has had standard functionality for awhile. If you’re unfamiliar with it, Microsoft has an overview of its functionality on their Dynamics 365 site. However, the following diagram also illustrates it quite nicely:
![Dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/d365aml1.png)
Azure Machine Learning is essentially a cloud-based predictive analytical solution. It replaces the SQL Server Analysis Services time series algorithm that AX 2012 uses. For D365 Demand Forecasting, we will use it to predict demand for future time periods based on historical demand. For this example, we’re using the standard demo data. Other than the parameters noted below, no other setup was required.
Dynamics 365 Setup
Our first task is to set up the Demand Forecasting parameters. Set the Forecast generation strategy on “Azure Machine Learning.
Master Planning Setup Demand Forecasting Demand Forecasting parameters
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml2.png)
Once set, the following warning will pop up.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml3.png)
Click on Message Details to reveal the remaining setup steps.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml4.png)
Deploying Azure Machine Learning Studio
Now it’s time to set up the experiment in Azure Machine Learning Studio. First, Visit the Demand Forecasting experiment in the Cortana Intelligence Gallery. The Cortana Intelligence Gallery is like an app store for Machine Learning.
Click the “Open in Studio” button to continue.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml5.png)
Next, sign up for an account. The free account will work fine for this example.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml6.png)
Once your account is active, you can deploy the experiment directly from the gallery and select an Azure region for deployment. Please note that if you are deploying D365 on-premises you will also need an Azure storage account.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml7.png)
Once deployed, we can see our Demand Forecasting experiment. The Studio shows two types of inputs—manual data and data received from a web service. In this scenario, the web service is D365. Below that, an R script generates our forecast, and then the calling web service splits and returns our data.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml8.png)
Inputs
Our experiment has three different inputs.
- Web service input – input received from Dynamics 365
- Sample Data – data used when we run the experiment as a standalone
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml9.png)
- Parameters – sample parameters used in conjunction with the sample data from above to run the experiment
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml10.png)
Generate Forecast
Written in R, a statistical computing and programming language, this is where the brains of the operation reside. R is in part named after the S statistical programming language on which it is based, and its creators, Ross Ihaka and Robert Gentleman from the University of Auckland.
In a gross over simplification, the script restructures and validates the data before generating the forecast based of the model we have chosen to use.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml11.png)
Split Data
The Split data step is a data transformation. We are splitting out dataset output from the R script into two groups, based on the value of the Type column. This gives us two datasets – one good and one with all errors.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml12.png)
Select and Return Datasets
Lastly, we select specific columns we want to return from the datasets and return these to the calling web service.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml13.png)
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml14.png)
Deploy the Web Service
We next need to run the script. This validates it so we can deploy the web service we’ll need next.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml15.png)
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml16.png)
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml17.png)
Once deployed, you’ll be able to grab the API key.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml18.png)
Click on the “API help page” for the REQUEST/RESPONSE to get the web service URL.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml19.png)
For the webservice URL, include everything up to the /execute?api… section, similar to the following example:
https://ussouthcentral.services.azureml.net/workspaces/12add345678901bb2ebb345eb67f890/services/123de45bc6c789012b34567ff89e
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml20.png)
Parameter Update
Finally, now we have what we need to update the Demand Forecasting parameters with our values obtained above.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml21.png)
Execution
Now that we’ve finished the setup, we can run demand forecasting from Master planning Forecasting Demand forecasting Generate statistical baseline forecast. In the parameters below, I selected to generate my forecast for the next three months.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml22.png)
And about 10 minutes later…
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml23.png)
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml24.png)
Now that it’s executed successfully, we can view the forecast from Master planning Forecasting Demand forecasting Adjusted demand forecast.
![dynamics 365 demand forecasting](https://www.sikich.com/wp-content/uploads/2018/06/ml25.png)
Have any questions? Don’t hesitate to contact us about setting this up for your Dynamics 365 scenario or with any other questions about the Dynamics family.