3

In QGIS Model Builder, I’m using an "enumeration" input that allows the user to select from multiple string values (e.g., "option1", "option2", "option3").

I want to use the selected value from this enumeration input in the Field Calculator to pre-fill a field with a filename, such as "file_option1.geojson".

My goal is:

The user selects a value from the enumeration input. That value is used in a Field Calculator expression to dynamically generate a filename or label.

Questions:

  1. How can I access the selected enumeration value inside the Field Calculator?
  2. What is the correct syntax to use this value in an expression?
  3. Is it necessary to define a variable or use another method to pass the value into the Field Calculator?

1 Answer 1

4

I have a model with an enumerate param input named enum, a vector layer param and a Field calculator. The enum param is outputting integers based on the chosen value, so I use a CASE WHEN to calculate output file name strings:

CASE
  WHEN @enum = 0 then 'out_file_1.geojson'
  WHEN @enum = 1 then 'out_file_2.geojson'
  WHEN @enum = 2 then 'out_file_3.geojson'
ELSE 'out_file_unknown.geojson'
END

enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.