---
title: Use the Switch Processor Function
slug: litmusedge/9MRgfyORz4_c71XFsXDJd
description: Learn how to use the Statistical Prediction function in Analytics. 
docTags: 
createdAt: 2024-02-28T19:18:17.892Z
---

In this guide, we will use the Switch Processor Function to manage the flow of data. You will understand the various rules applicable to the switch processor, how input messages are evaluated, and the significance of output filtering.&#x20;

# Before You Begin

- Get familiar with different rules of [Switch](docId\:M_F3yq3k6ZdQYhnoByXRR) processor. The rules for comparison are done through *GoLang strings.compare&#x20;*&#x66;unctions.

# User Scenario

Review the following scenario for the switch processor function. Then, using an input processor, you will simulate PLC data, apply certain rules from the Switch processor, and then output only when rule checks are met.

In a manufacturing plant, you can use the Switch Processor to evaluate incoming messages from sensors that detect product specifications, such as tags and weight. When a sensor reports a product that exceeds a predetermined threshold or set conditions, the Switch Processor checks this input against the available rules.&#x20;

If the condition is met, floor operators can be notified to inspect the assembly line for potential issues or alternatively an alert can be triggered. In this way, the Switch Processor helps ensure that only products meeting quality standards proceed down the production line, minimizing waste and enhancing overall operational efficiency.

# Step 1: Add a Device

Follow the steps to [Connect a device](docId\:pal6ABPZbrimdU9LvGJ30) 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 Tags](docId\:XgWOkQbTPevII7OR82LL0) to learn more.&#x20;

## Tag 1: TT1

- **Name**: Select **S - Random value generator**
- **Value Type:** Select **string**
- **Polling Interval**: Enter **1**
- **Tag Name**: Enter **TT1**

# Step 3: Create Analytics Flows

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 Switch Processor function:**

1. In Litmus Edge, navigate to **Analytics**.&#x20;
2. On the analytics canvas, clic&#x6B;**&#x20;Add processor**.&#x20;
   The *Create a processor* dialog box displays.&#x20;
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/ZdcpDTjKPrLwdKeFw6LWq_base-conversionadd-processor.png" size="80" width="1244" height="452" caption="The Add processor option" position="center" showCaption="true"}
3. Select **DataHub Subscribe**.
4. In the **Topic&#x20;**&#x66;ield, click the **Search&#x20;**&#x69;con, select the device you previously created, and then select the alias topic for the **TT1&#x20;**&#x74;ag.&#x20;
   ![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/AdCgZcKlrYLXkOnUTBkWY_a.png "Create a Processor dialog box")
5. Click **Save**.
6. Click **Add processor** again and select the **Switch&#x20;**&#x70;rocessor.
   The following information defines this function:
   - **Rule:** The *Rule&#x20;*&#x73;pecifies the condition to be checked.&#x20;
     For this example, we select **contains&#x20;**&#x72;ule from the drop-down menu.
   - **Field Name**: The *Field Name&#x20;*&#x69;ndicates the specific field in the input message for comparison. For this example, we input *value&#x20;*&#x61;s field.
   - **Check Value:** The *Check Value&#x20;*&#x69;s the value against which the *Field Name&#x20;*&#x69;s evaluated. For this example, we want '**h**' value to check for.
   - **Check Value Type:&#x20;**&#x54;he *Check Value Type&#x20;*&#x64;efines the expected data type of th&#x65;*&#x20;Check Value*. For this example, we input a value of **4**.
   - **Output (Optional):** The *Output&#x20;*&#x64;etermines where the result will be published or if it goes to all connected processors if left empty.
   - Click **Save**.
     ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/HD8yiR_e79LfLXF9L-SeA_image.png" size="80" width="756" height="512" position="center" caption="Edit a processor dialog box" showCaption="true"}
7. Connect the *DataHub Subscribe* processor (tag: *TT1*) to the *Switch&#x20;*&#x70;rocessor with a wire and use the **events&#x20;**&#x63;onnection.
8. On the analytics canvas, click **Save**.
   The configured analytics flows should look like the following:&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/YkpvgyK_YahsUb-i1n4xu_image.png" size="70" width="532" height="220" position="center" caption="Completed flows canvas" showCaption="true"}

# Step 4: View Output of Processor

Click the **View&#x20;**&#x69;con in the *Switch&#x20;*&#x70;rocessor to view the output values.

You can see the values that contain the letter '**h**' in the specified field are displayed in the output.&#x20;

![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/HYxJQmbrznWyc1kQrlEBp_image.png "Switch Processor Output")

