Hi guys,

I'm in automation and I'm completely new to PI and a it's been a while since I've coded so bear with me please!

I want to calculate what period of time a PI tag is in a certain state between a start and end time.

In Processbook I was able to achieve this using **TimeEQ('MyTag', '11-Oct-16', '*',"PAUSED")/3600** which returned the time in hours since 11-Oct that myTag was in the "PAUSED" state.

I want to use this calculation in a VBA script in Excel where the result(s) is presented in a barchart. I also want to have a form so the start and endtime can be entered.

Can anyone give me a pointer in how best to do this?

What PI calculation commands are available to me in Excel VBA? I have datalink add-on activated in PI and the PIDLdialogs referenced in VB.

Thanks in advance.

Gregor's answer is much simpler to implement but since you've asked for a VBA solution, I figured I'd provide that as well:

First, you'll need to include references to PISDKCommon and PISDK from the VBA Editor by going to Tools > References.

Once you've done that, this code will evaluate your performance equation and return it in cell A1.