Use ITEMLEVEL
to determine the position of a given item within its list. The list is identified based on the item's data type. You can use this function to find the distance from the item to either its root ancestor or its furthest leaf descendant.
Syntax
ITEMLEVEL(Item [, Direction])
Arguments
Argument | Data type | Description |
Item | List item | A list item whose distance to either the root ancestor or the most distant leaf descendant is to be returned. |
Direction (optional) | Keyword | Determines the direction in which the distance is measured. The keywords are
|
The ITEMLEVEL
function returns a numeric value.
Calculation engine functionality differences
This function is only available in the Polaris Calculation Engine.
Syntax example
ITEMLEVEL(Product1)
Consider the item Product1
, which belongs to a list called Products
. The function returns the number of items in the Products
list from Product1
to its root ancestor, including the item itself in the count.
ITEMLEVEL(Category1, LEAF)
Consider the item Category1
, which belongs to a list called Categories
. The function returns the number items in the Categories
list from Category1
down to its furthest descendant, including the item itself in the count.
Additional information
The function's result depends on the type of list and the list item's position within it. Key points include:
- The function counts only the items in the list. The list is identified based on the item's data type.
- Returns 0 if,
- In the
ROOT
direction, Item doesn't have a root ancestor. - In the
LEAF
direction, Item doesn't have any leaf descendants.
- In the
- If the list item has no root or leaf nodes within the specified list, the result is 0.
- If the list item is blank, the result is 0.
- Top-level items are treated as the (unique) root of the corresponding lists.
Examples
The following table represents the structure of a list Products
as displayed from the Tree View:
All products | |||
Electronics | |||
Laptops | |||
Gaming laptop | |||
Phones | |||
Furniture | |||
Chairs |
All products
has two children:Electronics
andFurniture
.Electronics
has two children:Laptops
andPhones
.Laptops
has one child:Gaming laptop
.Furniture
has one child:Chairs
.
Consider the following module with three line items:
Item
contains all the list items fromProducts
.Result 1
andResult 2
have theITEMLEVEL
formulas with the data fromItem
.
Item | Gaming laptop | Laptops | Phones | Electronics | Chairs | Furniture | All products |
Result 1 | 4 | 3 | 3 | 2 | 3 | 2 | 1 |
Result 2 | 1 | 2 | 1 | 3 | 1 | 2 | 4 |
ITEMLEVEL(Item)
counts the number of root ancestors the Item has, plus itself.ITEMLEVEL(Item, LEAF)
counts the number of items in the path to the Item's furthest descendant, plus itself.
Here, All Products
is at the top level, and its furthest descendent goes down 4 levels to Gaming laptop
, so ITEMLEVEL(All Products, LEAF)
returns 4. Gaming Laptop
is the furthest leaf item, so its root ancestor goes up 4 levels, and its leaf value is 1.