Greg
Greg

Reputation: 2609

Expression Builder in QGIS "left" or "strpos" not working

I have a table in QGIS with full names and I want to parse into first name(s) and last name. I’ve created the columns and am using expression builder to do this. Here's what I'm trying and it's not working. left( "name",strpos( "name", " ") ) with name being the full name. I've tried just putting in strpos( "name", " ") to see if things are working and nothing shows up. I click on Update Selected and nothing changes. I've tried putting the whole expression in last_name = "name",strpos( "name", " ") ) and no luck. QGIS on Mac OSX. PostgreSQL

What am I missing? Thank you.

Upvotes: 1

Views: 1141

Answers (1)

mkirk
mkirk

Reputation: 4040

Try this:

left( "name", strpos( "name", ' ') )

Explanation

In expressions "something" denotes a column called something.

So in your expression

left( "name",strpos( "name", " ") )

strpos takes a column and a string argument. You passed "name" for the column which is good, but your second argument " " is actually looking for a column called <space>. To quote a string, you use single quotes.

Upvotes: 1

Related Questions