# Custom Filter Functions

Custom Filter Functions provide the ability to make functions that will dynamically calculate a value for a filter using high level code.

Filter Functions can be written in C#, JavaScript, or VB. Net.

Filter Functions written in C# and VB.Net can get and set elements from the current session of Exago, such as Parameter values. See Exago Session Info for more information.

# Creating Filter Functions

To create a custom function, select ‘Date Functions’ in the Main Menu and click the Add button. This will open a Date Function tab.

Each Custom Date Filter Function has the following properties:

### Name

A name for the filter function that will be displayed to the end users.

### Description

> NOTE. To support multi-language functionality, if the filter function’s name or description prepended with ‘_wrFunctionId’ matches the id of any element in the language files, then the string of that language element will be displayed to the user instead of the function name/description.

- For the example function below you could create a language id ‘Begining_of_Month_wrFunctionId’. The string associated with this id would be displayed instead of the name. For more information see Multi-Language Support.

### Filter Type

Determines the "data type" of filters that the filter function should be available for.

### List Order

The order the filter function will appear among other filter functions of the same type. Functions with a lower number will appear higher on the list. If two functions have the same list value they will display in alphabetic order. All of the built in filter functions start with list value 100 or greater.

### Language

The high-level language of the code for the date function. May be C#, JavaScript, or VB.Net.

### Reference

A semicolon-separated list of any dlls that need to be referenced by the Date Function. If the dlls are not accessible in the GAC then the dlls must be copied to the 'Bin' folder of Exago or the reference should point to their physical path.

> NOTE. System.dll does not need to be listed as a reference as it is already available.

### Program Code

The program code for your Date Function. The code must return a DateTime value. Press the green check mark to verify the code executes properly.

> NOTE. Parameters may be referenced within custom functions by placing their name between @’s.

# Example

The following is an example of a Custom Function.

- Name – Beginning_of_Month
- Language – C#
- Program Code –

    // retrieve the first day of the current month
    DateTime now = DateTime.Now;
    DateTime FirstDayInMonth = new DateTime(now.Year, now.Month, 1);
    // return as date time
    return FirstDayInMonth;