2

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

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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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