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, if you use a time period value for the Item argument, the CODE function returns the time period value as text.
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
Example usage with lists as dimensions
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 Code
| SP001 | SP002 | SP003 |
Example usage with list-formatted line items
In this example, an Income Statement module has line items on rows, time on columns, and the Regions list on pages. 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 | John Johnson | John Johnson | Hannah Smith | Hannah Smith | Hannah Smith |
Sales Commission | 20,366 | 10,300 | 13,422 | 20,002 | 1,999 | 15,698 |
Personnel Code
| SP001 | SP001 | SP001 | SP003 | SP003 | SP003 |