
With the release of Prophet 2024 Q4, users may have noticed a notable enhancement in variable handling—the ability to define variables using enumeration types, in addition to the conventional number and text formats. This seemingly modest update introduces a practical tool that can significantly improve model clarity and coding efficiency.
For those less familiar with the concept, an enumeration functions similarly to a structured list, pairing integer values (starting from 0) with corresponding text descriptions. This dual-reference system allows seamless conversion between numeric and text forms—enabling users to reference elements either by name or index.
Illustration: Using Enumerations for IFRS17 Discount Rates
Consider an example where an enumeration is created to represent IFRS17 discount rate types, named IFRS_DISC. The structure might look like this:
- 0 paired with “LIR” for locked-in rates
- 1 paired with “VIR” for current rates
These can then be referenced using notation such as IFRS_DISC.LIR and IFRS_DISC.VIR—a syntax that resembles object-oriented principles familiar to VBA or other modern programming languages.
Prophet supports several built-in functions to facilitate the use of enumerations:
- ENUM_TO_INT and ENUM_TO_TEXT for extracting integer or text values
- INT_TO_ENUM and TEXT_TO_ENUM for converting standard values back to enumeration types
Practical Application: Improved Code Readability and Structure
The primary benefit of using enumerations lies in enhancing the transparency of model logic. Rather than relying on hard-coded numeric values—e.g., IF CALC_LOOP = 0 THEN—users can write more descriptive and self-explanatory conditions:
IF CALC_LOOP = ENUM_TO_INT(DISC_TYP.LIR) THEN
This approach reduces ambiguity and improves maintainability, especially in models maintained by larger teams.
Further, by defining an enumeration-type variable, such as CALC_DISC, to automatically convert CALC_LOOP to its corresponding enumeration, even conversion functions become unnecessary. The condition simplifies to:
IF CALC_DISC = DISC_TYP.LIR THEN
This not only streamlines logic but also enables additional functionality. For instance, where table suffixes must vary by t or CALC_LOOP, enumeration variables can be used to construct suffixes dynamically—something not feasible with text variables alone:
"ifrs_disc_" + ENUM_TO_TEXT(CALC_DISC) + "_pc"
Conclusion
The introduction of enumeration as a variable type in Prophet is a thoughtful and practical enhancement. While modest in scope, its benefits are tangible—promoting clearer logic, reducing the risk of manual errors, and encouraging a more structured coding approach.
For Prophet users aiming to build models that are easier to interpret, maintain, and scale, enumerations offer a straightforward yet powerful solution. We encourage incorporating this feature into your workflow where applicable—it’s a simple adjustment that can bring lasting improvements to your model quality and consistency.