PI Vision how-to
Create Dynamic On-Demand Calculations in PI Vision
Build a PI Vision display that lets users choose a time range, trigger an AF Analysis, and inspect the calculated result without creating a separate analysis for every range.
Before you start
This workflow uses an AF Element as the contract between the display and the calculation. Prepare the element, its attributes, and the analysis before you build the PI Vision display.
- Decide which attributes hold
StartTime,EndTime, the trigger, the input values, and the output. - Confirm that the display user has permission to write the input and trigger attributes.
- Choose the interval boundaries, time zone, units, and no-data behavior before testing.
- For the display controls, Quick Input+ is the matching Vision Library+ control. The Vision Library+ documentation covers the wider symbol collection and setup information.
Design the handoff first: the operator should be able to see the selected interval, the trigger state, the output value, and when the result was last calculated.
Step 1
Create the AF Element and its attributes
Create an AF Element that gives the calculation a stable home. Use clear names so the AF Analysis and the PI Vision display refer to the same contract.
Define the selected interval
Create attributes for StartTime and EndTime. Decide whether the end boundary is inclusive and how the display time zone maps to the AF timestamps.
Add a deliberate trigger
Create a trigger attribute or event path. The trigger should change when the user is ready to run the calculation, not on every keystroke while the interval is being edited.
Map inputs and output
Reference the PI Points or AF Attributes used by the expression, then expose the calculated result through an output attribute with a documented unit and meaning.

Step 2
Build the AF Analysis
Create the AF Analysis that evaluates the selected interval. The analysis should read the time attributes instead of using a fixed time range in the expression.
- Reference
StartTimeandEndTimeas the calculation boundaries. - Use the input attributes in the expression and define how missing data is handled.
- Set the execution mode so the analysis runs when the selected inputs or trigger change.
- Write the result to the output attribute and make the unit and result type clear.

Step 3
Configure when the calculation runs
A trigger separates editing the inputs from executing the calculation. Use the option that fits the workflow:
- Trigger from a
StartTimeorEndTimechange when the result should update immediately. - Use a dedicated trigger attribute when the user should review the full interval before execution.
- Make pending, completed, and failed states visible to the user.
- Avoid triggering on every display refresh unless that behavior is intentional and tested.

Step 4
Build the PI Vision display
Expose the inputs and output on one display. Quick Input+ can provide controls for StartTime, EndTime, and the trigger. Add a native Value Symbol or another suitable PI Vision element for the output.
- Label the start and end values and show the expected time format.
- Keep the trigger near the inputs it acts on.
- Show the output unit and, where useful, the selected interval.
- Show a last-calculated timestamp or status so users can identify a stale result.

Step 5
Test the complete path
Test from the display input to the AF output. A successful run means the selected timestamps reach the analysis, the analysis executes, and the expected value is written and displayed.
Use a known interval
Choose a range with an expected result and record the time zone and boundary behavior used by the test.
Run the trigger
Change the configured trigger and confirm that the analysis receives the new timestamps and inputs.
Check the result
Compare the output value, timestamp, unit, and quality with a known-good calculation or direct data query.
Repeat with edge cases
Test a reversed interval, no-data range, short range, repeated trigger, and a user without the required write permissions.

| Symptom | Check first | Useful test |
|---|---|---|
| Output does not change | Trigger path, analysis execution, or stale display value | Change the trigger directly and compare the output timestamp. |
| Wrong interval is used | Time zone, attribute mapping, or boundary logic | Test one known start and end timestamp at each handoff. |
| Analysis fails for some ranges | Missing data, invalid input, permissions, or expression assumptions | Run a short known-good range, then expand it. |
| Display shows a stale result | Refresh behavior or output configuration | Show the last-calculated timestamp and reload after a trigger. |
Common questions
On-demand calculation FAQ
Why use a trigger instead of continuous recalculation?
A deliberate trigger lets the user finish selecting the interval before the analysis runs. It also makes the execution point easier to test.
Can users change the time range from PI Vision?
Yes, when the controls are connected to writable AF attributes or another approved input path. Make the time format and permissions clear.
What should the display show besides the result?
Show the unit and, where useful, the selected interval and last-calculated timestamp so users can distinguish a fresh value from an earlier result.
