EF Duration Attribute Using Formula Data Reference

Blog Post created by bbregenzer on May 28, 2020

Several years ago I posted an Idea on PI Square to use the Formula data reference (DR) as a standard way to configure a Duration attribute on event frames.  Long story short, the Idea on PI Square was lost during some backend changes* and since I still get questions on this topic, I'm resurrecting it as a blog with a few edits.  Please see below.

This is a followup to discussions with Roger Palmen and Rick Davin about their excellent writeups on the topic of EF Duration attributes; see Event Frame duration - easy way in AF2.6 or higher & Duration attribute on an Event Frame - Part 1 , respectively.

With the addition of the %Duration% substitution parameter in AF 2017 ( and its support in the Formula Data Reference, the following is suggested as a standard way to add a Duration attribute with values in a UOM from the Time class for newer versions of AF.

Create an EF attribute template with the following configuration:

Note 1: no parameters need to be defined; the substitution parameter is put directly into the Equation and can even be retrieved from the "helper" menus (red box and arrows).

Note 2: As mentioned in Rick's blog, the Formula DR supports unit conversions so we can change the result produced by %Duration%, which is in seconds, to any other UOM in the Time class (from seconds to hours in the example above; blue boxes).

Note 3: A third method not shown here or the referenced links above is the use of EF Generation analysis outputs to add duration to EFs (see KB01884).

  • Pro: using Outputs on close is a nice, all-in-one method if you also want to output the duration to a PI Pt attribute on the reference element where it can be used elsewhere (e.g., real-time dashboards or calculations in AF).

Note that you can choose to have the output written only to a static EF attribute so you just get Duration on the EFs (nothing on the reference elements), but using this has the following cons:

  • Con: Because the output expressions are not evaluated until the EF closes, there are no intermediate Duration attribute values available for open EFs.
  • Con: This method is more complex to configure and maintain when Duration attributes for EFs are used widely.  For every event frame generation analysis where we want the EFs to have a duration attribute, we need to add the Duration output expression.  Using the Formula approach above, the Duration attribute can be configured on a base EF template from which other EF templates can be derived.

Note 4: As mentioned in a followup post from Rick, you can use %Duration% in a String Builder DR attribute with Value Type set to <Anything> in order to produce a time span (i.e., formatted like dd:hh:mm:ss).  This is the same as what is produced by the Duration property of the EF.

For further details/discussion, please see the comments under Rick's blog.

Please comment here to let me know what you think of this.
Thanks for your time!


*Surprisingly, the old linked feedback item still exists even though the PI Square Idea was lost. ¯\_()_/¯