Analytics Manager > Using the Tutorials > Tutorial: Create a Discrete Analysis Event
  
Tutorial: Create a Discrete Analysis Event
During the course of this tutorial, you will learn how to create an analysis provider and an analysis model. Once you enable the analysis model, you can create a discrete event on the TW_AS_DiscreteDemo_AdditionDiscreteThing thing. You can use the TW_AS_DiscreteDemo_AnalysisDiscreteDemoMashup demo mashup to generate jobs and view results.
1. Create the analysis provider.
* 
Note the following points:
In the Provider Name (Required) field, enter the name of the provider as ExcelProvider.
In the Connector (Required) field, click the icon, and select the TW.AnalysisServices.Excel.ExcelConnector connector.
For more information about creating an analysis provider, refer to Create an Analysis Provider.
2. Start the Microsoft Excel agent.
The Excel agent is packaged with the Analytics Extension. If the agent is not already installed, install and configure the agent so that it connects to your ThingWorx server. For more information, refer to Configure the Microsoft Excel Agent.
3. Create an Excel workbook for model computation. For the demo, you can use the Sample Excel Workbook provided for download in the Reference Documents section of the PTC eSupport Portal, or create your own. For details on how to set up the workbook, see Create an Excel Workbook.
4. Create an analysis model.
* 
Note the following points:
Ensure that the name of the model is addition in the Model Name (Required) field.
Enable the model that you have created.
For more information about creating an analysis model, refer to Create an Analysis Model.
5. Create an analysis event by entering the following details in all the fields:
a. In the Source Type (Required) list, select Thing.
b. In the Source (Required) list, click the icon to search for and select the TW_AS_DiscreteDemo_AdditionDiscreteThing thing.
You do not need to create the TW_AS_DiscreteDemo_AdditionDiscreteThing thing. This thing is available with the ThingWorx Analytics Extension.
c. In the Event (Required) list, select DataChange.
d. In the Property (Required) list, select FirstInput.
e. In the Provider Name (Required) list, select the provider (ExcelProvider) that you created in Step 1.
f. In the Model Name (Required) list, select the model (addition) that you created in Step 3.
g. Click Save to save the analysis event.
6. Complete the following steps to map inputs and results of the analysis event to the properties of the TW_AS_DiscreteDemo_AdditionDiscreteThing thing:
a. Select the analysis event that you created in Step 5, and click Map Data.
b. Click Inputs Mapping to map the properties of the TW_AS_DiscreteDemo_AdditionDiscreteThing thing to the input data shape.
c. In the Source Type (Required) field, select Thing from the drop-down list.
The TW_AS_DiscreteDemo_AdditionDiscreteThing is displayed in the Source (Required) field automatically.
d. Create the following input mappings:
Map the FirstInput property to the input data shape a to get the following input mapping:
a[NUMBER]=0.0 <-- TW_AS_DiscreteDemo_AdditionDiscreteThing[FirstInput]
Map the SecondInput property to the input data shape b to get the following input mapping:
b[NUMBER]=0.0 <-- TW_AS_DiscreteDemo_AdditionDiscreteThing[SecondInput]
e. Click Results Mapping to map the result data shape to the properties of the TW_AS_DiscreteDemo_AdditionDiscreteThing thing.
f. Create the following result mapping:
Map the results data shape c to the ResultOfAddition property to get the following result mapping:
c[NUMBER]=0.0 --> TW_AS_DiscreteDemo_AdditionDiscreteThing [ResultOfAddition]
For more information about inputs mapping, see Map Input Data. For information about results mapping, see Map Result Data.
7. On the Analysis Events page, select the event, and click Enable to enable the analysis event.
8. In ThingWorx Composer, search for and view the TW_AS_DiscreteDemo_AnalysisDiscreteDemoMashup mashup.
After you load this mashup in your browser, you can execute and observe analysis jobs.
9. Enter any value in the First Input and the Second Input fields, and click Calculate to get the job status, and the result.
The mashup checks the job status every 2 seconds and displays it in the Job Status field. After the job is completed, it displays the result in the Result of Addition field.
* 
Since the event trigger for the property is set on DataChange on the value of FirstInput, the result is not updated if you change the value of the SecondInput only.
10. Alternatively, in ThingWorx Composer, you can change the value of the FirstInput property on the TW_AS_DiscreteDemo_AdditionDiscreteThing thing to trigger the event, and thus generate an analysis job.
You can also check the status and results of the analysis jobs. For more information, see Managing Jobs.