GETDIFF returns the difference between values of a specified expression or variable, with an optional roll-over correction for meter values. GETDIFF is an Advanced Math Toolbox Function.
SYNTAX:
GETDIFF(Exp, DateRange, optional TimeIncrement, optional RollOverFactor)
where :
Exp is any valid WIMS Expression
DateRange is an expression in one of two forms:
1. StartDate TO EndDate
StartDate is a date literal. If StartDate is NoDate, then the function does not calculate and returns the value BLANK.
EndDate is a date literal. If EndDate is NoDate, then the function does not calculate and returns the value BLANK.
2. TimeRangeLiteral
A TimeRangeLiteral Defines start and end dates for a time interval specified. For a listing of available literals, refer to the TimeRange Literal List.
TimeIncrement is an optional parameter that specifies the time frame of the calculation. Default is BYDAY (Daily). For a listing of available literals, refer to the TimeIncrement Literal List.
RollOverFactor is an optional parameter that specifies the rollover point for calculating the difference. This should be used when calculating the difference of metered values that have specific rollover points. (NOTE: Unlike the other Advanced Math Toolbox Functions, this calculation requires exactly two values to calculate; therefore, the "Number of Values" optional parameter is not necessary and has been replaced by RollOverFactor.)
NOTES:
The Advanced Math Toolbox Functions give full flexibility to WIMS users to create new calculations that are not currently available with the existing, predefined functions. Since these functions are very general and very powerful, they do not have a lot of safety checks built into them and must be used with caution. The advanced functions will generally be slightly less efficient than the predefined functions and are not therefore intended to replace the predefined functions.
The main feature of the advanced functions is the ability to specify the date range for the calculations explicitly in the function call. This allows nonstandard time frames to be used for summation, averaging, geometric means, etc. The functions also allow calculations within the function call and thus are no longer limited to just working on a single variable. (i.e., you can now take the sum of C2 * C3)
The range of the advanced functions can be specified in two ways:
-
By explicit dates (i.e., sum all values from the beginning of the month to the end of the month.) See
Date Literals for more information on specifying dates.
-
By maximum number of values within a date range (i.e., sum the first 5 numbers from the start date to the end date) These range specifications apply to most of the custom functions.
See Also: DDFN(Vx) and DDIF(Vx) standard Math Toolbox Functions
EXAMPLES:
Example 1: Calculate the difference between daily values of an existing variable, with rollover.
GETDIFF(C3, D, GETDATE(C3, D-1 TO D-7), 250000)
C3 : Calculate the difference between values of variable 3
D : Today
GETDATE(C3, D-1 TO D-7) : To the most recent value, looking backward up to a week
250000 : The values in variable 3 have a rollover point of 250,000