Tiering & Scale

These events take a numeric value and return an array based on breakpoints.

Certain business operations take a value, like 500, and break it apart into smaller pieces. Each piece could represent the amount of demand for a certain item, or the number of units requested at a particular price.

To support the modeling of these operations, SEL has functions that split numeric values into arrays, called Tiering and Scale.


Like the name implies, Tiering defines a set of tiers, using the following syntax:

=Tiering([5, 10, 20])

This establishes 4 tiers: 0-5, 6-10, 11-20, and 20+.

When this function receives a number, for example, 13, it will find the tier 13 belongs to -- in this case, the third tier: 11-20. Because 13 belongs in the third tier, this function will return:

[0, 0, 1, 0]

This 1 points to the tier the input value belongs in.

From here, we can send this [0, 0, 1, 0] to an expression, like * [49, 99, 149, 249], which could represent the price of each tier. This multiplication expression would return the value 149 because 1 * 149 = 149.


The Scale function defines a set of ranges with breakpoints, like so:

=Scale([150, 250, 500])

This establishes 4 ranges: 0-150, 151-250, 251-500, and 501+.

If the value 1000 were sent to this function, it would return:

[150, 100, 250, 500]

150 units fit inside the first range, another 100 inside the second, then 250, and then the remaining 500 into the final (highest) range of 501+.

From here, we can send this list to an expression like * [1.99, 1.49, 1.25, 0.99], which could represent the value or price of each unit in each range.

When the output of the Scale, a list, is multiplied by another list, SEL returns the single numeric dot-product of the two lists. In this case: (1.99 x 150) + (1.49 x 100) + (1.25 x 250) + (0.99 x 500) = 1255.


Lists vs. Single Values

Tiering and Scale are special insofar as they return a list, which can only be sent to event types capable of receiving a list.

At the time of this writing, the only events capable of receiving a list are math expressions that begin with +, -, /, or * and end with a number or list.

To resolve a list into a single number, you must return a dot product.