Formula about accessing the penultimate value of a variable in PiVision or Pi System Explorer

Hello everyone,

I'm currently working with PiVision and Pi System Explorer for data visualization and analysis, and I have a specific query regarding accessing historical data.

Is there a built-in functionality or method within PiVision or Pi System Explorer that allows me to retrieve the penultimate (second last) value of a variable, irrespective of timestamp? I understand that these tools are primarily geared towards visualizing current and historical data, but I haven't found a straightforward way to access the value immediately preceding the current one without relying on a specific timestamp.

 

Aim: We track the feed and product tanks in our DCS and read the values into Pi. Our operators want to see the current tank number and the second last tank number which has been used for the unit.

 

Thank you in advance for any assistance or advice you can provide!

Best regards

  • Since you didn't specify the engine: performance equation or analyses, I will provide a one-line solution that will work in either.

    Assume your tag or attribute is called 'Metered Value':

    TagVal('Metered Value',FindNE('Metered Value','*','*-30d','Metered Value'))

     

    FindNE - Get the timestamp 'Metered Value' between now and 30 days back where the value is not the current value of 'Metered Value'; the search starts at 'now' and goes backwards

    TagVal - Get the value of 'Metered Value' at the timestamp provided by FindNE

  • Hey Marcus, a solution that can be used in PI Vision could be a custom symbol. One example is our PI Vision Value Table. You can configure it to show the last "x" values in the past. If you hover with your mouse over the value you can also see the current timestamp.

    In this example you can see a short demo example where you have a tank. Below we have our table that is configured to show the last 5 values. Only the first two values are even in the current value range. The rest is retrieved unrelated to the current Display Range.


    image.png
    This symbol is part of our Werusys PI Vision Suite: Werusys PI Vision Suite - Customized Symbols at your Conditions

     

    We just recently released version 2024.1: Werusys PI Vision Suite – Update 2024.1 - werusys

     

    Beside of that we can also create a custom tailored symbol exactly for this use case. If you want to have a look at this live you can also drop me a message: julian.weber@werusys.de