--- title: "Examples of Simple Formulas" slug: "examples-of-simple-formulas" updated: 2024-02-02T18:12:06Z published: 2024-02-02T18:12:06Z canonical: "kb.dataparc.com/examples-of-simple-formulas" --- > ## Documentation Index > Fetch the complete documentation index at: https://kb.dataparc.com/llms.txt > Use this file to discover all available pages before exploring further. # Examples of Simple Formulas ### Filter OV = IV If IV < MinVal Or IV > MaxVal Then FILTER = True ### Average of Tags within a Range 'This formula averages the value of up to three tags if their values 'have good quality and are between 0 and 10,000 'Shows example of dimensioning variables Dim iCount As Integer Dim dSum As Double Dim PV As PARCValue iCount = 0 dSum = 0 PV = IV(TAG1) If PV.Quality <> Opc.Da.Quality.bad Then If Convert.ToDouble(PV.Value) > 0.0 And Convert.ToDouble(PV.Value) < 10000.0 Then iCount = iCount + 1 dSum = dSum + Convert.ToDouble(PV.Value) End If End If PV = IV(TAG2) If PV.Quality <> Opc.Da.Quality.bad Then If Convert.ToDouble(PV.Value) > 0.0 And Convert.ToDouble(PV.Value) < 10000.0 Then iCount = iCount + 1 dSum = dSum + Convert.ToDouble(PV.Value) End If End If PV = IV(TAG3) If PV.Quality <> Opc.Da.Quality.bad Then If Convert.ToDouble(PV.Value) > 0.0 And Convert.ToDouble(PV.Value) < 10000.0 Then iCount = iCount + 1 dSum = dSum + Convert.ToDouble(PV.Value) End If End If If iCount > 0 Then OV = dSum/iCount Else OV = 0 End If ### Tag Comparison 'Sample Formula to compare two tags value and return a 3rd or 4th tag's value if one has a value greater than the other. If IV(TAG1) > IV(TAG2) Then OV = IV(TAG3) Else OV = IV(TAG4) End If ### Show Text as Output 'An example formula showing how to output text in a calc formula. 'In this formula, if the value is less than 3 it will say "Low" as the tag's value and if greater than 3 then it will show "High" as the value If IV < 3 Then OV = New PARCValue("Low", Opc.Da.Quality.good) Else OV = New PARCValue("High", Opc.Da.Quality.good) End If