

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to use PEEK-function with condition?
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?
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Almost an too easy solution, but it works fine! Thanks Felip!


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad it helped
