QGIS – How can you truncate values in QGIS?

Marketing
Marketing
  • Updated

By David Crowther 

26.JPG

Question:

How can you remove characters from the end of a cell within QGIS? 

Answer:

Using the QGIS Field Calculator you can run an update script that can remove a designated number of characters from any cell within your data.

For example I have a Planning Applications layer and would like to remove the last 3 values (App) from the Name field, to generate the value ‘Planning’ instead of Planning App.

26.png

Using the Field Calculator tool within the Attribute table, you can use a Substring query to remove the last 4 values (as you will likely want to remove the Space character as well).

Choose to update an existing field, in this case the ‘name’ field. 

Then type the following text: 

substr("name",0,-4)

27.png

This will update the current values in the ‘name’ field by removing 0 characters from the left and 4 characters from the right hand side of the field. After pressing OK, the script will run and the values will be updated with 4 characters removed from the right.

28.png

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.