Difference

Calculates the difference between the current period value and the opening value.

Return Value

Returns a string of characters representing the correct expression to be used as part of the HS.EXP function.

Syntax

Difference (PointOfView, View)

Table 12-7 Syntax of Difference Function

Parameter Valid Values

PointOfView

Valid combination of Account, Custom1….4, ICP members, for example, "A#CASH.C1#[None].I#[ICP Top]"

View

Must be one of these values:

"" (double quote) - Based on the default view defined for the scenario being processed (either YTD or Periodic).

YTD - Specify the Year-to-date option, which overrides the default view set for the scenario.

Periodic - Specify the periodic option, which overrides the default view set for the scenario.

Detailed Description

This function calculates the difference between the value of the current period and the opening value. (Current - Opening)

The opening value is derived differently based on the View parameter passed to the function.

  • If the View parameter is YTD, the opening value is retrieved from the last period of the prior year.

  • If the View parameter is Periodic, the opening value is retrieved from the prior period of the current year. If the current period is the first period of the year, the opening value is retrieved from the last period of the prior year.

  • If the View parameter is blank ( " " ), the opening value is based upon the default data view of the scenario.

Example

The CASH account will return the following values for January, February, and March 2014 depending on the View parameter used in the Difference function. The default view set for the scenario being processed is YTD. The Difference function subtracts the opening value from the current period value.

Table 12-8 Example of Difference Function

Account Dec2013 Jan2014 Feb2014 Mar2014

A#Cash

900

1,200

1,100

1,500

Difference("A#Cash", ""

N/A

300

200

600

Difference("A#Cash", "YTD")

N/A

300

200

600

Difference("A#Cash", "Periodic")

N/A

300

-100

400

Sample Script

' sample statement written in the calling routine
Sub Calculate()
Hs.Exp  = "A#DiffCash" & Difference("A#Cash", "YTD")
End Sub
' programming of the DIFFERENCE function
FUNCTION DIFFERENCE(strPOV,strVIEW)
IF strVIEW =  "" THEN 
strVIEW = HS.SCENARIO.DEFAULTVIEW ("") 
END IF
strPOV = UCASE(strPOV)
strVIEW = UCASE(strVIEW)
IF strVIEW = "PERIODIC" THEN
DIFFERENCE = ""
            "&" 
            "&strPOV"-& strPOV & ".P#PRIOR" &"")""
         
ELSEIF strVIEW = "YTD" THEN
DIFFERENCE = "" ("&strPOV &"
            "-" & strPOV & ".Y#PRIOR.P#LAST" &"") ""
         
ELSE
EXIT FUNCTION
END IF
END FUNCTION