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.

CODE(Item)

ArgumentData typeDescription
ItemList or time periodThe 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.

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.

When adding codes to list items, you can manually add or import codes from the Grid View of the corresponding list.

LOOKUP

This example uses a list Sales personnel, which is shown below as displayed in the Grid View.


ParentCode
John Johnson
SP001
Barbara Jones
SP002
Hannah Smith
SP003

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 JohnsonBarbara JonesHannah Smith
Length of service (years)682
Commission rate %3.25%3.5%2%
Personnel code
CODE(ITEM(Sales personnel))
SP001SP002SP003

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 21Feb 21Mar 21Apr 21May 21Jun 21
Sales staffJohn JohnsonBarbara JonesJohn JohnsonHannah SmithBarbara JonesHannah Smith
Sales commission 20,36610,30013,42220,0021,99915,698
Personnel code
CODE(Sales staff)
SP001SP002SP001SP003SP002SP003