MDE Script Tip: Take Variable Number of Tags Into Formula Based on Which Have Input Values
- 05 Oct 2023
- Print
- PDF
MDE Script Tip: Take Variable Number of Tags Into Formula Based on Which Have Input Values
- Updated on 05 Oct 2023
- Print
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Generally, an MDE script only fires if all input tags being called with the Cell function have an input value. However you can make a script that takes a variable number of input cells into account by writing a script like this:
The results look like:
Full script text:
'Code:
Dim sum As Double
Dim cnt As Double
Dim avg As Double
If Cell("Plantname.MDE.BW_R").HasValue Then
cnt += 1
sum += Cell("Plantname.MDE.BW_R").Value
End If
If Cell("Plantname.MDE.BW_M").HasValue Then
cnt += 1
sum += Cell("Plantname.MDE.BW_M").Value
End If
If Cell("Plantname.MDE.BW_L").HasValue Then
cnt += 1
sum += Cell("Plantname.MDE.BW_L").Value
End If
If cnt > 0 Then
OV = sum / cnt
Else
OV = Nothing
ClearTagCellValue(C.DataUTag)
End If
Was this article helpful?