The CODE function returns a list item's code.
For example, you can use the CODE function to ensure that a formula only applies to a specific employee in a list.
Syntax
CODE(Item)
Arguments
Argument | Data type | Description |
Item | List or time period | The list item or time period to return the code of. |
The CODE function returns a text value. If a list item does not have a code, the CODE function returns a blank value.
Calculation engine functionality differences
In Polaris, if you use a time period value for the Item argument, the CODE function returns a blank text result. In the Classic Engine, it returns the time period value as text.
In Polaris, you can't use this function for line items that have the Formula or Ratio summary methods. In the Classic Engine, you can.
Additional information
When adding codes to list items, you can manually add or import codes from the Grid View of the corresponding list.
Excel equivalent function
Examples
Convert a list item to a Text
This example uses a list Sales personnel, which is shown below as displayed in the Grid View.
Parent | Code | |
John Johnson | SP001 | |
Barbara Jones | SP002 | |
Hannah Smith | SP003 |
Example with a list as dimension
In this example, a Sales commission rates module has line items on rows and the Sales personnel list on columns. The Personnel code line item has a Text data type.
The formula uses the ITEM function to identify the list item in the Sales personnel list, and the CODE function to return the code of that list item.
John Johnson | Barbara Jones | Hannah Smith | |
Length of service (years) | 6 | 8 | 2 |
Commission rate % | 3.25% | 3.5% | 2% |
Personnel codeCODE(ITEM(Sales personnel)) | SP001 | SP002 | SP003 |
Example with list-formatted line items
In this example, an Income statement module has line items on rows and time on columns.
- The Personnel code line item has a Text data type
- The Sales staff line item has a List data type on the Sales personnel list
The formula uses the CODE function to return the code of the corresponding list item in Sales staff.
Jan 21 | Feb 21 | Mar 21 | Apr 21 | May 21 | Jun 21 | |
Sales staff | John Johnson | Barbara Jones | John Johnson | Hannah Smith | Barbara Jones | Hannah Smith |
Sales commission | 20,366 | 10,300 | 13,422 | 20,002 | 1,999 | 15,698 |
Personnel codeCODE(Sales staff) | SP001 | SP002 | SP001 | SP003 | SP002 | SP003 |