---
title: Use the Compliance and Loss KPI
slug: manufacturing-connect-edge/use-the-compliance-and-loss-kpi
docTags: 
createdAt: 2024-08-08T22:02:02.212Z
---

The **Compliance and Loss&#x20;**&#x4B;PI mainly deals with manufactured units and defective units.

For this KPI, two input definitions are required: `manufactureEnd` and `defectiveUnit`. These are event triggers, signifying the end of the manufacturing cycle and the discovery of a defective unit, respectively. When the input tag associated with the *defectiveUnit&#x20;*&#x67;oes from one value to another, it indicates that the unit was defective.

The compliance rate is calculated by subtracting the number of defective units from the total manufactured units. The loss percentage is defined as the ratio of defective units to the total manufactured units.

# User Scenario

Review the following scenario for the compliance and loss KPI processor. Then, using an input processor, you will simulate PLC data and calculate the compliance rate and production loss.

In a manufacturing setting, the Compliance and Loss KPI is essential for monitoring product quality. For instance, a production manager can use this KPI to identify manufacturing issues and ensure product quality. For example, if 40 out of 100 products are defective, it indicates a 40% production loss, prompting the need for process improvement to maintain high-quality standards.

# Step 1: Add a Device

Follow the steps to [Connect a Device](docId\:nm1lQfefyA-DSIfFitIty) and configure the following parameters:

- **Device Type**: Simulator
- **Driver Name**: Generator
- **Enable Alias Topics**: Select the checkbox.&#x20;

# Step 2: Add Tags

After connecting the device, add the following tag. See [Add a Tag](docId\:h5heqIcXrCY3NCH9KBg9I) to learn more.&#x20;

## Tag 1: manufacture

- **Name**: Select **S - Random value generator.**
- **Value Type:** Select **float64.**
- **Polling Interval**: Enter **1.**
- **Tag Name**: Enter **manufacture.**

## Tag 2: defective

- **Name**: Select **S - Random value generator.**
- **Value Type:** Select **float64.**
- **Polling Interval**: Enter **1.**
- **Tag Name**: Enter **defective.**

# Step 3: Create Analytics Flow

You can now create the analytics flows using data from the device and tag you previously created.&#x20;

**To create an analytics flow with the Compliance and Loss Processor function:**

1. In Manufacturing Connect Edge, navigate to **Analytics**.&#x20;
2. On the analytics canvas, click **Add processor**.
   The *Create a processor&#x20;*&#x64;ialog box displays.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/h75-hvrlQg-O2j4ZqtAuD_image.png" size="80" width="800" height="305" position="center" caption="The Add processor option" showCaption="true"}
3. Select **DataHub Subscribe**.
4. In the *Topic&#x20;*&#x66;ield, click the **Search** icon, select the device you previously created, and then select the alias topic for tag1: **manufacture**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/oBw8Wrt_hKSBsZNP_2fnr_image.png" size="80" width="800" height="400" position="center" caption="Create a Processor dialog box" showCaption="true"}
5. Click **Save**.
6. Repeat steps 2-5 to add another *DataHub Subscribe&#x20;*&#x70;rocessor for the **defective&#x20;**&#x74;ag.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/SI4qAqU-jmRsqglfmiW12_image.png" size="80" width="644" height="334" position="center" caption="Canvas flow with two DataHub Subscribe processor" showCaption="true"}
7. Click **Add processor** again and select the **Compliance and Loss&#x20;**&#x70;rocessor.
   The following information defines this function:
   - **Defective From & Defective To:&#x20;**&#x49;f your input changes *Defective From* value to *Defective To* value, it will trigger a defective unit.
   - **Manufacture From & Manufacture To:&#x20;**&#x49;f your input changes *Manufacture From* value to *Manufacture To* value, it will trigger the end of the manufacturing cycle.
   - **Time Interval:** If the tag publishes at the expected interval, it is better to disable this timer by entering **0** in the field.
   - Click **Save**.
     ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/CkIqcBXk9hhAHbHahR1hv_image.png" size="80" width="1127" height="758" position="center" caption="Edit a Processor dialog box" showCaption="true"}
8. Connect the *DataHub Subscribe* processor (tag: *manufacture*) to the *Compliance and Loss* processor with a wire. Use the **Events** connection and enter a definition of **manufactureEnd&#x20;**&#x66;or the connection.
9. Repeat step 8 for tag: *defective&#x20;*&#x61;nd enter a definition of **defectiveUnit** for the connection.
10. On the analytics canvas, click **Save**.

The configured analytics flows should look like the following:

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/JxyPU_VrnfiYj_ky_lCCY_image.png" size="80" width="612" height="248" position="center" caption="Completed Flow Canvas" showCaption="true"}

# Step 4: View Output of Processor

Click the **View&#x20;**&#x69;con in the *Compliance and Loss* processor to view the output values.

The output displays the calculated compliance rate and production loss using data from the previously created device and tags.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/isX_OmLCjfVQEL1E3AE3j_image.png" size="80" width="866" height="344" position="center" caption="Output of Compliance and Loss processor" showCaption="true"}

