---
title: "SPC:Perspective:Script:Configure SPC Analysis in Script"
id: "spc-perspective-script-configure-spc-analysis-in-script"
project: "Tutorials"
url: "https://docs.sepasoft.com/articles/mes-module-tutorials/spc-perspective-script-configure-spc-analysis-in-script"
updated: 2026-07-23T18:14:00Z
---

# SPC:Perspective:Script:Configure SPC Analysis in Script

## Configure SPC Analysis in Script

Create a new view **SPC\_03\_Scripting/Reporting**

The Reporting page has two components:

[Ignition Button](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-input-palette/perspective-button)

[Ignition Table](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-table)

**![](/resources/Storage/mes-module-tutorials/spc-perspective-script-configure-spc-analysis-in-script/spc-perspective-script-configure-spc-analysis-in-script-2025-08-22.png)**

### Configure 'Generate SPC Data' Button

* Drag an Ignition **Button** component onto the middle of the window. Resize it enough to fit the text shown above.
* Change the **Text** property to ***Generate SPC Data***.
* RIght-click the button , select **Configure Events**, select the **onA** **ctionPerformed**event script area and paste in the script below (change the date range, if necessary, to span your data entries)


```python
def runAction(self, event):
	##Configure an Analysis Setting within script
	end = system.date.now()
	begin = system.date.addHours(end, -8)
	
	analysis = system.mes.analysis.createMESAnalysisSettings('analysis')
	analysis.setDataPoints("Dimension Sample B-Diameter.SampleUUID,Dimension Sample B-Diameter.Sample Value,Dimension Sample B-LocationX.Sample Value,Dimension Sample B-LocationY.Sample Value")
	analysis.setFilterExpression("Equipment Path = 'New Enterprise\Site\Area\Line 1\Test Location'")
	analysis.setGroupBy("Dimension Sample B-Diameter.SampleUUID")
	results = system.mes.analysis.executeAnalysis(begin, end, analysis)
	# getDataset() returns an Ignition Dataset
	# For documentation, see: https://docs.inductiveautomation.com/display/DOC79/Datasets
	dataset = results.getDataset()
	
	
	###Example of calling a previously existing Analysis Setting.
	#endDate = system.date.now()
	#beginDate = system.date.addDays(endDate, -3)
	#results = system.mes.analysis.executeAnalysis(beginDate, endDate, 'Door Placement')
	
	self.getSibling("Table").props.data = dataset
```
