Now up to this point in the class we've been ignoring
a field called Filtered Data.
So let's go back and revisit some of our previous
retrievals. This was the Compressed Data retrieval.
And we
had ignored this Filter Expression when we originally
did this. We weren't interested in doing any filtering. The Filter
Expression uses a Performance Equation syntax
to specify the criteria under which you
should retrieve data. It's actually
kind of a misnomer. We call it a Filter Expression, but, in fact,
I guess a better name for it would be the
Include Expression because you're only going to see the results
when that Expression is true. Let me go ahead
and demonstrate. Again, here is our existing
retrieval of Compressed
Data. We got 16 Values. It was from Yesterday
to Today. And, if we look at the definition --
I'll right-click and choose Compressed Data -- we see
that we're just retrieving this particular tag,
Sinusoid, between that Start Time and End
Time. So you can see the associations there.
There is no Filter Expression at this point. I've deliberately left
that blank. Now, watch what happens
if I simply use a
cell reference to this right here, this Filter Expression.
Now the Expression is Sinusoid Greater Than 50.
What this is going to do is it has the effect
of only retrieving data for when that
Expression is true. Would you call that a filter?
I don't know. We, we've, we call this
the Filter Expression Historically it's been used for
filtering purposes so we name it the Filter Expression,
but don't get confused about what its effect is.
The fact is we only retrieve those Values for
when that Expression is true, and we can prove that
because if I change this to Less Than 50, for example,
and now we see the results are
only when that Expression is true.
Now I would imagine that some people at this point and time are
saying well, hold on a second. What's this Performance Equation syntax all
about and why in the world does that start with two single quotes?
That's actually two single quotes, not a double quote. So, let's get into
this. What is this Performance Equation syntax that I've just
mentioned? If you looked at the earlier videos, you saw
a section on Performance Equation syntax that
referred you over to our PI PC
Directory, that you'll find generally under Program Files. Under Help
you'll find a file called PE Reference, and under
PE Reference you'll find a lot of information
about the Performance Equation syntax. This is an
Expression Syntax that has a series of built-in
functions that are specifically designed
for people in, you know, working with real-time data.
It's got great Functions you can make use of. You know,
how long has something of Value been greater than
X?, etc. So, all these great Functions,
all this great syntax that's available, you know, we have an
If-Then capability.
It's, it's a nice Performance Equation, or a nice
Expression Syntax, but it does, it is
its own Syntax, although there are --
it does resemble some other Syntax you may be familiar with. There
are some peculiarities. So, for example,
one of the peculiarities is that when
referring to PI Tag Names, those tag names have to begin
with single quotes, so, those of you who are
Excel experts right now, you may be recognizing oh,
okay, that's why he did it. See, the reason you have to
start this with two single quotes is because
Excel interprets a single quote in a cell
as a format specifier indicating that what follows
is text. So, if I just started off
with a single quote, you would end up looking
like that. You would have, you would, it would basically
ignore that first
single quote as the contents of the cell. So you end
up having to do two single quotes. Well, to be
honest, I find that so clumsy and awkward I would much
prefer to suggest to you, whenever
you're using Performance Equation syntax, just put the whole
darn thing inside parentheses. It doesn't affect
the Expression one bit, and it gets around this whole
problem of using two single quotes to start out.
I mean, two single quotes. My goodness. I can't imagine anything more
confusing to the guy who picks this up and tries to use it
than to run into that. So, I think it would be much better
if you stick with that convention.
Now, I've just
shown you how to do this using a
simple PI Compressed Data Option. What I didn't
mention is, if you notice what's happening when you do this,
it's actually changing that Function. It goes from
being a PICompDat Function to a PICompFilDat
Function. Let me demonstrate. Let me show you
with the Sample Data. See, here's a similar
retrieval in which, instead of Compressed Data, now
I'm retrieving Sample Data. This is 24 hours of
Data, 1-hour Interval, so I should see about 25 Values.
If I use Area, that's what I see. And now I'd like
to filter that. So, in order to filter this, let me put
in an Expression, oh, let's
say, let's choose a different tag this time,
CDT158. It's an unrelated
tag, because, of course, you can do anything you want here. Let's say
(CDT158 is greater than 150),
for example. That's my
Filter Expression. Now, I did put it in parentheses just
to avoid that problem with the two single quotes. Now watch
what happens. I'm using PiSampDat.
When I switch this over
and, whoops, you can't really see that. Let me bring that up on the
screen. There we go. When I switch this over,
bring this up for Sample Data and add the Filter Expression
watch what happens to this PISampDat.
I go ahead and say OK. It
changes to PISampFilDat
because we're actually changing the Function for you. So the dialog
box is doing that work for you. And, as you can
see, we've gotten a sub-set of the data.
Now let's say at this point you have given this to
lots of people, and they say oh, this is great. I would like to
see, though, when there has been filtering,
because what we're seeing here is we see there's filtering,
we can tell that filtering is occurring, but we don't
see where it was occurring. We could guess it was right here
'cause of the big gap in time, but we don't really
see it indicated. So, if that's the situation,
you know, and this, and this is what you distributed to people, you could go
back in and make some additions
so that those filterings would be shown. Let me go ahead and change
my settings to get rid of that Disable.
And since I'm going to go in here and edit this, every time
I click on this, I'd like this to bring up the
dialog box again so I can do my edits
more easily. Yeah, so here's what I'm talking about. I can
go in here, choose this option called Mark
As Filtered, and that will indicate where the
filtering has occurred. So, now, it is going to
show me where one or more Values have been
filtered, so there may be many Values that have been filtered from
this particular section right here. Yeah, that's
between 4 pm and 1:30
am, so there's probably more than
one thing that's been filtered there. Similarly here,
if I choose Mark as Filtered,
go ahead and say OK, now we see that the filtering
has occurred.