FTYPE( ) function
Returns a character identifying the data category of a field or variable, or the type of an Analytics project item.
Syntax
FTYPE(field_name_string)
Parameters
Name | Type | Description |
---|---|---|
field_name_string | character |
A field name, variable name, or Analytics project item name. Enclose field_name_string in quotation marks: FTYPE("Amount") |
Output
Character. This function returns one of the following characters, which indicates the field, variable, or Analytics project item type:
- "C" Character field
- "N" Numeric field
- "D" Datetime field
- "L" Logical field
- "c" Character variable
- "n" Numeric variable
- "d" Datetime variable
- "l" Logical variable
- "b" Analytics script
- "y" Analytics table layout
- "w" Analytics workspace
- "i" Analytics index
- "r" Analytics report
- "a" Analytics log file
- "U" Undefined
Examples
Basic examples
The following example assigns a value of 4 to the num variable and then checks the type.
Returns "n":
ASSIGN num = 4
FTYPE("num")
Advanced examples
Testing for the data type of a field
You have a script or analytic that requires a numeric Amount field, and you need to test that the field is the correct type before running the script.
The following command only runs Script_1 if Amount is a numeric field:
OPEN Invoices
DO Script_1 IF FTYPE("Amount") = "N"
Testing if a table or Analytics project item exists
The following command only runs Script_1 if a table named Invoices is present in the project:
DO Script_1 IF FTYPE("Invoices") <> "U"