# Formula to create condition based on multiple criteria and analysis

## Recommended Posts

Hey there,

My question splits into two parts:

Firstly, I want to create a condition based on multiple criteria: if signal A equal to 3, B equal to 4, C is greater than 5 than condition is valid. I know i could create 3 individual capsule and overlap them. Is there a simple way to use formula to do so?

Secondly, in my analysis i have 10 signals and associated conditions(alert), then I want to know in the past 7 days how many alert in total(repeated instance or capsule doesnt count) ? and How long is the total alert time?

Thank you

##### Share on other sites

Hi Felix

You can use Seeq's formula tool to do this.  In this case I have 3 string signals (Compressor Stage for Areas A, B and C).  I want to know when Area A and B are both off at the same time Area C is in Stage 1.  Instead of doing the Value Search in the tool, I do it in formula.  If you don't know how to do the value search in formula you can always do it in the tool and then click the 'i' by it in the details pane to get to Item Properties where you can see the formula used.

Once I do my three value searches

```\$condition1= \$cs.ismatch('Off')
\$condition2 = \$cs2.ismatch('Off')
\$condition3= \$cs3.ismatch('Stage 1')```

I then do a composite condition.  In this case I want to know when all three are true so I use intersection but you can always search for combining conditions to get more options.

`\$condition1.intersect(\$condition2).intersect(\$condition3)`

The whole formula is below:

```\$condition1= \$cs.ismatch('Off')
\$condition2 = \$cs2.ismatch('Off')
\$condition3= \$cs3.ismatch('Stage 1')

\$condition1.intersect(\$condition2).intersect(\$condition3)```

This this tells me when Area A and B are both off at the same time area C is running in stage 1.

• 2
##### Share on other sites

For the second part of your question.  You will first need a capsule that captures the time period you are interested in.  We usually recommend a Weekly Periodic Condition.

Once you have the weekly periodic condition you have two options:

Signal from Condition: use this tool to count the number of times the conditions are true each week.  You then can use the 'i' in the details pane to get to item properties.  At the bottom you can duplicate the first signal from condition and do another one that switches out the count statistic for the total duration statistic.  You will need to do this for each of your items. Scorecard Metric: Use this option if you want a table view.  You will follow similar options to generate the scorecard. In this case we will use a conditional scorecard. You will repeat the same procedure for duplicating using the i by item properties and switching the statistic from count to total duration. The skills you have asked for here are covered in our Interactive Training which you may want to visit here -- https://www.seeq.com/interactive-training/story.html

Morgan

• 2
##### Share on other sites

I tried your solution, it didnt quite give me what i wanted. I should re rephrase my questions as following:

I have 10 alerts set up, depends on the signal value the max number of alert from equipment is 10. I am interested in knowing in the past week, how many equipment has triggered the alert?

From your solutions, it gives me how many alert capsule has in the past 7 days. Monday, Tuesday has alert, the result is 2. But I would like to know how many equipment went wrong.

Does this make sense?

p.s: how can i insert a snapshot to here? It ask me to insert image from URL

Edited by Felix Jing
##### Share on other sites

Hi Felix,

you may try this one. I have set up an example with three assets:

I used the following formula to calculate the number of failed equipments: The formula iterates over each week and calculates the number of failed equipments for each capsule of the weekly condition. Therefore I am using the sign() function on the number of capsules per week, which returns 1 if capsules exists during the week and 0 if no capsules are present. The sum of these values is used for a new sample that is set at the beginning of the capsule. toStep() connects each sample using step interpolation.

Regards,

Thorsten

• 2

## Create an account

Register a new account