Hello,
Shouldn't you be using the time range that you used in the PercentTrue method rather than "EarliestTime" and "MostRecentTime"?
Also, you may need to use a smaller sample time if you are looking over a larger time range. There is a good explanation in the PISDK help file...e.g.
Quote:
The PercentTrue result is computed by summing up intervals where the passed expression is evaluated to true. The arguments SampleType and SampleInterval are used to determine expression evaluation intervals as discussed in the table below. More frequent expression evaluations leads to more accurate result but increases server load. Therefore, care must be taken to avoid overloading the server by specifying too fine a calculation granularity.
...
fstExpRecValWithMinSampTime
This option allows the user to get more accurate answer than the fstExpRecordedValues option by evaluating the expression more frequently. Normally, this option is only necessary if the expression involves comparison of analog tag values. Also, the PI 3 server limits SampleInterval to between 1/100 and 1/10000 of the calculation period. PIAPI uses this option for PI 3.x servers.
Principal Consultant
Real-Time Data Management @ Wipro Technologies