ENUM
Basic Overview
Description | Iterates through the rows of the input and assigns a number to each row in ascending or descending order based on the magnitude of measures. Order: Allowed values are "ASC" for ascending and "DESC" for descending. |
Signature | ENUM('Node' [, “Order“]) |
Parameters |
|
Limitations |
|
Example 1:
Input:
Node A
Year | Measure |
---|---|
2021 | 7 |
2022 | 5 |
2023 | 3 |
2024 | -2 |
Applying ENUM('Node A') will simply produce the following. Here enumerating is done only based on measures.
Year | Measure |
---|---|
2021 | 4 |
2022 | 3 |
2023 | 2 |
2024 | 1 |
Applying ENUM('Node A', “DESC“) will produce the enumerated result starting from largest measure value.
Year | Measure |
---|---|
2021 | 1 |
2022 | 2 |
2023 | 3 |
2024 | 4 |
Example 2:
Dimensions & Levels:
Time → Year
Product Dimension → Product Family, Product
Input:
Node B:
Year | Product Family | Product | Measure |
---|---|---|---|
2021 | Car | Big Car | 6 |
2022 | Truck | Big Truck | -5 |
2023 | Car | Small Car | -5 |
2024 | Truck | Small Truck | 9 |
Applying ENUM('Node B') would yield:
Year | Product Family | Product | Measure |
---|---|---|---|
2021 | Car | Big Car | 3 |
2022 | Truck | Big Truck | 2 |
2023 | Car | Small Car | 1 |
2024 | Truck | Small Truck | 4 |
In this case enumeration starts from lowest measure which is -5 which there is a tie on two rows. Function “prioritises” Product dimension over “Time” since the name is alphabetically appearing earlier. Within the product dimension “Product Family” is the upper level in hierarchy that is why this level is used to break the tie and the row with the “Car” gets the first value over “Truck“. There is no other tie in the measures so enumeration continues as usual for the rest of the rows.
Input:
Node C:
Year | Product Family | Product | Measure |
---|---|---|---|
2021 | Car | Big Car | -5 |
2022 | Truck | Big Truck | -5 |
2023 | Car | Small Car | -5 |
2024 | Truck | Small Truck | -5 |
2025 | Car | Small Car | -5 |
Applying ENUM('Node C') would yield:
Year | Product Family | Product | Measure |
---|---|---|---|
2021 | Car | Big Car | 1 |
2022 | Truck | Big Truck | 4 |
2023 | Car | Small Car | 2 |
2024 | Truck | Small Truck | 5 |
2025 | Car | Small Car | 3 |
In this more complex case every measure is equal. As mentioned in the previous example the level “Product Family” is prioritised to break the tie however there is a another tie as rows 1, 3, and 5 are all sharing the same value “Car”. In this case the function looks at the next available level in dimension which is “Product” and the row with the “Big Car” is enumerated with value 1. Row 3 and 5 still share the same value (“Small Car“) which in this case the function will look at the Time dimension (“Year”) to resolve the final conflict.