Dear Members of the PISquare community,

With the following PI AF attributes:

- Length

- Coil Id

- Measurement

With PI Web API, I would like to get the "Measurement" value when the "Coil Number" is equal to a particular value and at the moment where Abs('Length' - 12500) is the smallest value.

How can I do this ?

Thanks,

Best regards,

Nicolas

Hi Nicolas,

The definition of 'smallest' value is vague. You will need to have a time range to be able to define a smallest value.

You can use a combination of

FindEq: to find the timestamp when the "Coil Number" is equal to a particular value within a time range -> Timestamp1

TagMin: to find the smallest value within a time range and then FindEq to find the timestamp of the smallest value -> Timestamp2

if Timestamp1 and Timestamp2 are the same, then proceed to use that timestamp with TagVal to find the value of Measurement.

if they are not the same, then abandon it.