Using the Custom Statistics Editor

The Custom Statistics Editor is used to create and edit custom SPC or DMS statistics you can use in GainSeeker. These are created using Python scripts in GainSeeker.

Creating custom statistics with Python script

 

Contents  [Hide]

 

Accessing the Custom Statistics Editor

The Custom Statistics Editor opens from the New and Edit buttons on the Custom Statistics List window.

Using the Custom Statistics Editor window

Label

Enter a name for the statistic. In the GainSeeker Charts module, this will be the statistic name displayed to the user.

Internal statistics number

GainSeeker automatically assigns a unique ID number to each statistic you create.

Value type

Choose how GainSeeker should format the value of this statistic: String, Number, Percent, Cost, Count, or Other.

If you choose Other, you also need to enter a Custom Format for this statistic. See Numeric Formats and Date/Time Formats.

IronPython Script

Enter a Python script that sets the value of the newstat variable to the desired value.

An easy way to reference the value of another GainSeeker statistic is to place your cursor at the desired location and then double-click that statistic in the Existing statistics list. (To search for a statistic, type any part of its name or ID number in the Search existing box.) This will insert the Python command to get that statistic's value at the current location of your cursor. More GainSeeker Python commands are also available.

To undo your most recent change, click the Undo button.

Script Testing

Click Test to view the result of your IronPython Script and Value Type. Your new statistic will be displayed in the newstat= box as it would appear in the GainSeeker Charts module.

Click Launch Debugger to launch the Python Script debugging tool.

Note: The Test and Launch Debugger buttons use a sample data set to calculate your custom statistic. If you prefer to debug and edit your custom statistic using your own real-world data, follow these steps:

    1. In the GainSeeker Inspections module, use the Manage Python button to create a new Python script (for standalone use).

    2. Add a Retrieval Action to your new script and customize it to retrieve the desired data.

    3. Copy the IronPython Script from your custom statistic (in the System Administration module) and paste it below the Retrieval Action script (in the GainSeeker Inspections module).

    4. Use the tools in the Python Script Editor to debug and/or edit your script until the newstat variable returns the desired value.

    5. Copy the custom statistic code from the new script (in the GainSeeker Inspections module) and paste it into the IronPython Script for your custom statistic (in the System Administration module).

Python Reference, Python Tutorial, and Hertzler Library

Helpful links that open appropriate topics in a web browser or in the GainSeeker Online User Guide.

Script Versions

This grid displays all previously saved versions of the current statistic.

When you double-click a previous version of the statistic listed in the grid, it replaces the current statistic after you hit Save. If you replaced the current version with an earlier version in error, click the Undo button to revert back to the current version.

The number of versions that are saved is determined by the Custom Statistics - Previous script version to retain = setting in the System Administration module.

Example of creating a custom statistic

In this example, set the Label, Value Type, and the IronPython Script field as shown. The output shown in this example is 0.733, based on an example "Total Defects" statistic of 733.

This acquires the total number of defects and assigns it to the variable totaldefects:

totaldefects = statdms.getstat(18)

This sets the special variable newStat to the value of totaldefects divided by 1000:

newstat = totaldefects / 1000

Note: newstat must be set to the final desired value of the custom statistic.