
Returns the code of a list item. When you use the function on:
- a list, the Code returned is configured in the Grid View.
- a time-formatted line item, the function returns the selected time as text.
Syntax
CODE(x) where:
- x: line item to evaluate
Format
Input Format | Output Format |
---|---|
x: List item, time period | Text |
Arguments
The function uses the following arguments:
- x: List-formatted or time period-formatted line item
Constraints
The function has the following constraints:
- Source must be list-formatted or time period-formatted.
- Result must be text-formatted.
- If selected list item in source has no code defined, return is blank.
Excel equivalent
Example
List-formatted example
In this example, a list Sales Personnel has a Code assigned to each list item in theGrid View:
The model contains a simple Income Statement module with line items on rows, a time dimension on columns, and Organization and Versions as pages. A Sales Staff list-formatted line item has been added to the module, that is formatted on the Sales Personnel list and allows a list item on the list to be selected for each region for each quarter. We can then use CODE in the text-formatted Sales Personnel Code line item to show the selected salesperson's code:
CODE(Sales Staff)
List as a dimension
In this example, we have a simple Sales Commission Rates module belonging to the same model as the list-formatted example above, where the Sales Personnel list is used for the columns. We can then add a text-formatted Personnel Code line item. We use the ITEM function to return the list item used as the column heading by nesting it in the CODE function. This then returns the Code held for each of the column labels:
Time-formatted list
We can use a line item that is list-formatted to a time period as an argument.
The function:
CODE(Selected Month)
+ added to Selected Month as CODE converts the selection in Selected Month to text format.