Home : Products : Hach WIMS : Hach WIMS Client : Documentation : Function Reference : Math Toolbox Functions : Difference Functions : MDIF
Q10822 - INFO: MDIF

MDIF calculates the difference between values stored on the last day of current and previous month for the specified variable.  This difference is placed on the last day of the month. 

SYNTAX:

MDIF(Cx, Optional Rollover)
where :
Cx is a conditional variable x
Rollover is an optional parameter used to specify the rollover point of the input variable, Cx.

NOTES:

The specified variable, Cx, MUST have a value in the last slot of the month for the month being calculated for the equation to return a value.  For example, if Cx is a daily variable and you are calculating for October 2014 you must have a value on October 31st, 2014.  If Cx is an hourly variable you must have a value on October 31st, 2014 in the 11PM slot. 

However, the MDIF function will search for a value in the previous month.  For example, if Cx is a daily variable and you are calculating for October 2014, MDIF will search the last 8 days of September to find a value and if a value is not found will search October 2014 for a value.  (See Determining Previous Month's Last Value below)

In most situations, it is STRONGLY RECOMMENDED that you have a value in last slot (last day for daily, last hour of hourly, etc...) of every month in variable Cx.

If the Optional Rollover parameter is not specified, the system assumes the rollover point is at the next power of 10; therefore, you will never have a negative difference. (See Example 2 below)

EXAMPLES:

EXAMPLE 1: V105 = MDIF(V104)

Variable 105 will contain the monthly difference of variable 104:

EXAMPLE 2: V130 = MDIF(V129)

Calculates the monthly difference of the values stored in variable 129 and records the difference in variable 130, on the last day of the month.

Date V129 V130 Comment
1/31 20    
2/29 10 90 rollover occured during the month, assumed at 100 (next power of ten)
3/31 6 96 rollover occured during the month, assumed at 100 (next power of ten)

 

DETERMINING PREVIOUS MONTH'S LAST VALUE

In most situations, it is STRONGLY RECOMMENDED that you have a value in last slot (last day for daily, last hour of hourly, etc...) of every month in variable Cx.  If there is not a value in the last slot for every month, MDIF will search for the the last value using the following rules.  The examples below assume we are calculating for Janurary.

  1. If there is a value on the last day of the previous month, it will be used.
    Example: Cx is a daily variable and there is a value on 12/31
    Example: Cx is an hourly value and 12/31 11:00 PM has a value, it will be used as last value.
     
  2. If there is no value on the last day (or slot for daily detail variables), then we will search backwards in time for up to 8 days. (E.g. Dec 24 - 31) 
    Example 1: 12/24 6:00 AM has a value, and no other values through the end of the month. It will be used as last value.
    Example 2: 12/23 11:00 PM has a value, and no other values through the end of the month. It will NOT be used because it is out of range.
     
  3. If no value is found in step 1 and 2, then we will search the current month starting on the first, going through the second to last day. (E.g. Jan 1 - 30)
    Example 1: There were no values found in December. 1/1 2:00 PM has the first value in January. It will be used for last value.
    Example 2: There were no values found in December. 1/30 11:00 PM has the first value in January. It will be used for the last value.
    Example 3: There were no values found in December. 1/31 1:00 AM has the first value in January. It will NOT be used because it is on the last day of the month.
     
  4. If there are no values within the valid range, the value will be assumed to be 0.
    Example: There is a value on 12/23 11:00PM and no other values until 1/31 1:00 AM: The system did not detect any values within a valid range and will use a value of 0 in determining the difference between December and January.
Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 2/29/2008 2:58 PM.
Last Modified on 2/9/2015 12:04 PM.
Last Modified by No Author Name Available!.
Article has been viewed 4661 times.
Rated 5 out of 10 based on 10 votes.
Print Article
Email Article