Analyzing Data with the Analysis Expert

A function is a special form of an expression that performs a complex calculation or action before returning its value.

Example:Example:

The function Today() retrieves the computer's current date and then translates it to the number of days that have passed since January 1, 1900. That number becomes the value of the function.

Functions expand the scope of what a PracticeScript expression can tell you. Using a function such as Today() combined with a comparison operator such as = enables you to find out if certain transactions were posted on the current date. The PracticeScript variable Ledger.SvcDate represents the service date of a ledger transaction.

The expression: Ledger.SvcDate = Today() evaluates to TRUE (1) if the transaction contains the current date.

The syntax of a function is similar to that of a variable. It differs from a variable in that it is always followed immediately by an expression, or parameter, enclosed in parentheses. A parameter supplies the information that a function uses to make its calculation. Some functions have optional parameters.

Example:Example:

The function FirstOfMonth() evaluates to the number of days between January 1, 1900, and the 1st of the month that includes the date specified as the parameter. If no parameter is specified, the current date is assumed.

If you use a numerical expression that represents a different date, the function evaluates to the first of the month of the alternative date.

Example:Example:

The expression FirstOfMonth(Today() - 7) calculates the number of days between January 1, 1900, and the 1st of the month that includes the date 7 days prior to the current date.

 

Related Topics

Creating a New Analysis Expert

Using the Analysis Expert Spreadsheet