Okay, no answers for the question.

For future reference (if others have the same problem and find this posting) :

You can use an array constructor together with the array_get function

i.e., if you have an Enum processing input  "animals" with values like "Gorilla","Snake" and "Elephant", you can get the enum textual value by using this construct:

*array_get(array('Gorilla','Snake','Elephant'),@animals)*

It's not pretty - but it much shorter than writing a potentially humongous CASE..WHEN construct. An even better method would be to use a (hypothetical)  function that returns a list of enumeration texts based on the name of the input, like

*array_get(enum_texts('animals'),@animals) *or - even better -***enum_text('animals',**@animals**)*

However, i haven't found these hypothetical functions.

Med venlig hilsen / Best regards

Bo Victor Thomsen

On 10/06/2025 12.35, Bo Victor Thomsen wrote:
Hi list -

I'm designing a processing model, where i use a "Enum" input. When accessing this variable in a "Calculate Expression" algorithm in the model, the result will be an ordinal value - not a text - from the enum.

Example:
I have an enum named "animal" defined with 3 animal names like "Gorilla","Snake","Elephant". If the user choose "Snake" the variable @animal contains the number "1" instead of "Snake". How do I get the textual representation of the enum instead of the ordinal ?

I'm aware I can use a CASE... WHEN in the expression. But it will be cumbersome for enums with many values.
_______________________________________________
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to