Check your calculations to validate them before checking them in
I find this feature one of the most useful ones for debugging expressions. Before you start your analyses and/or backfill results, it is always a good idea to validate your expressions are doing what you expected. To do this, use the Preview Results selection and export the results to Excel if need be. The example below shows the details. (Note: To be able to Preview Results the expression must not contain any errors and if you are in the Template, you must select an Example Element.)
The first thing to do is to split up the expression into multiple expressions and Variables. In this example, the expression is split into four Variables; PumpOn, PumpOff, Flowing, and Status (see Make AF Analytics more readable - Break up your calculations blog). The first three are True/False checks and the last one is the determination of the status. This is a simple example, but it illustrates the benefit. When we preview the results, we get the trigger timestamps and the values of the above four Variables, as well as the values for all the Attributes in this Analysis, at the trigger times.
Contrary to popular belief, you do not need to check-in anything to preview the results. (So I would advise you to refrain from checking-in all the time, it is a waste of time unless you want to make the specific changes you just made available to other PI AF client tools. Also, be aware that if the analyses created from this Template are running, every time you check-in, these analyses will
restart.) To preview results, we right click on the Analysis Rule, Pump Status in this example, and select Preview Results.
Next, we select a start time and end time of interest and click the Generate Results button. The results will be generated as shown in the above Figure. Notice that the FlowRate
Attribute values are also added to the result set. Any Attributes that are used in the expressions will also be added to the result set. The next thing to do is to export the data to a csv file by clicking the Export Results button. We can then open it in Excel and use filters or sorting to check that the conditions for the expression are working as expected for a historical data set.