Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In my application, I want to fill unknown datafields with historical values from the last row with the same TagID (first column). In the actual situation the positions with the red values are empty. I filled in the red values to show what they should be.
A normal PEEK-function can use the data from a fixed previous record, but how to program the condition to copy from a previous record with a certain condition?
Hi,
For the peek to work, you'll have to order your data.
In this case, order it by TagID and TimeStamp so you can have a table with the historic view, by TagID. like so:
orderedTable:
Load *,
if(peek(TagID)=TagID,peek(MTBF),MTBF) as MTBF
Resident dataTable
order by TagID,TimeStamp;
Next, you use the peek() statement to check something like this:
if(peek(TagID)=TagID,peek(MTBF),MTBF)
this if will verify if the previous tag ID is the same as the current one and then get the according MTBG value.
Hope it helps,
Felipe.
Hi,
For the peek to work, you'll have to order your data.
In this case, order it by TagID and TimeStamp so you can have a table with the historic view, by TagID. like so:
orderedTable:
Load *,
if(peek(TagID)=TagID,peek(MTBF),MTBF) as MTBF
Resident dataTable
order by TagID,TimeStamp;
Next, you use the peek() statement to check something like this:
if(peek(TagID)=TagID,peek(MTBF),MTBF)
this if will verify if the previous tag ID is the same as the current one and then get the according MTBG value.
Hope it helps,
Felipe.
Almost an too easy solution, but it works fine! Thanks Felip!
Glad it helped