I'm working with a column in an attribute table that has number values and NULL values. I want to create a new column in which NULL values are changed to "Directory" and any number values to "Submitted."

I used the formula from the answer from How to do a simple find and replace in QGIS field calculator? and successfully converted NULL to text.

enter image description here

How can I use a version of this formula to also convert all number values to the word "Submitted"?

3 Answers 3


Add a "New_Field" of type Text. Select the values that are not NULL using "Select features using an expression" from the attribute table, and enter the following formula:

"Field_Name" is not null 

Where: "Field_Name" is the field that contains numbers (is not NULL). Then update the "New_Field" and write 'Submitted' in the expression, and use Update Selected, as shown below:

enter image description here

Then use Invert Selection enter image description here and write 'Directory' and click Update Selected.


If you want to verify if content is number, then try the below regexp:

CASE WHEN regexp_match(( "Field_Name" ) , '[0-9]') THEN 'submitted'  END

Use this expression to return 'Directory' for values of NULL and 'Submitted' for values containing a digit in the attribute named fieldname:

when fieldname is NULL then 'Directory'
when fieldname ~ '[0-9]' then 'Submitted'

Like this, if field is not NULL and does not contain any digit, the output will be empty. You might define an else condition to set an output for such cases.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.