Q10528 - INFO: LV

LV(Cx, SearchDays, Offset) Returns the last value entered for the variable specified.  Searching begins based on the offset specified and will stop when a value is located or after the spcified number of SearchDays have been searched.  If no data is found the result is a blank.  The variable to be searched must be specified as a Conditional Variable (use a "C" instead of a "V").

SYNTAX:

LV(Cx, SearchDays, Offset)
where :
Cx is a conditional variable x
SearchDays:  Specifies the number of days to search beginning on the offset date. SearchDays must be a value other than 0.  Keep in mind that as the value of SearchDays increases, the equation may take much longer if it does not find a recent value.  If the value of SearchDays is negative, the function will search ahead to find the next value in the future.

Offset: Specifies the number of days (or data slots for daily detail variables, e.g. hours for hourly variables) to add or subtract from the current date and begin searching. For example:

-1 = Yesterday's for a daily variable, previous hour for an hourly variable,...
0 = Today
1 = Tomorrow for a daily variable, next 15 data slot for a 15 minute variable,...

EXAMPLES:

Search back up to 366 days for a value.

V132 = LV(C120, 366, 0)

Searches variable 120 for the last value entered. Begins searching on the current date, and looks back as far as one year (I used 366 in case of leap year).  As soon as a value is found, that value is returned and the function stops searching.

Search foward up to 31 days

Note: If the value of SearchDays is negative, this function will search ahead to find the next value in the future.

V132 = LV(C120, -31, 1)

Searches variable 120 for the next value entered. Begins searching with tomorrow's date, and looks ahead as far as 31 days.  As soon as a value is found, that value is returned and the function stops searching.

Search a Daily Detail variable

V132 = LV(C90, 48, -1)

Searches variable 90 (Variable 90 is an hourly parameter)for the last value entered.  Searches V90 starting yesterday at 11 PM reading (the last reading of yesterday) going back up to 48 days.

Hourly Calc, search a Daily Detail variable

V130 = LV(C90, 7, -1)

V130 is an hourly calculated variable.  Searches variable 90 (Variable 90 is an hourly parameter)for the last value entered.  Searches V90 starting at the previous hour going back up to 7 days.

Use LV and Force to set psuedo constants

V130 = LV(C130,2,-1)

Then Force a value into V130 and the LV calc that value every day until you Force a new value.

 Related Articles No Related Articles Available.

 Article Attachments No Attachments Available.