1

I have two questions about virtual fields:

Is it possible to move a virtual field? I'm using Table manager to move "normal" fields but virtual fields doesn't show.

Is there any simple way to convert a virtual field to a normal field? Or even converting all virtual field in a layer at once?

  • Can you shortly elaborate on "move". Is this the order within the different fields of a layer or between different layers? – Matthias Kuhn Oct 20 '15 at 15:42
  • I mean the order within the different fields. If Table manager would work, I would use the "Move up" and Move down" button. – Helena Oct 20 '15 at 16:35
2

Virtual fields are a pure QGIS concept. The data provider (your database) does not know the slightest bit about their existence. Virtual fields are just put "on top of" the real data, their values are temporarily regenerated by QGIS every time they are required somewhere.

The table manager works closely related to the data provider, so it also does not work with virtual fields.

Virtual fields are always appended to the end of the attribute table (just like joined fields as well). This position is determined by QGIS, you do not have any control over it. The only control you have is between multiple different fields by defining them in the appropriate order.

To materialize a virtual field, you can use the attribute table and create a new non-virtual field based on the virtual field with the expression "[virtual-field-name-goes-here]". Once you have materialized this field, you can order it in the table manager just like any other field. At the expense of no longer having automatically updated values.

Edit based on Helena's comment

To get a snapshot of the current state of the layer into a separate file, it's possible to use save As, since this will also include virtual fields.

  • Thanks for your reply! I guess I just have to accept not being able to control my virtual fields. But when it comes to materializing them, is it possible to do that with several fields "with one click"? I have a project where a lot of data is interrelated in virtual fields, but I need to be able extract a "stable" shape file with all the information. Would have been great to for example save a copy and being able to just tick in a box "convert all virtual fields to normal fields". – Helena Oct 20 '15 at 17:02
  • To do that you will need to write some python code. – Matthias Kuhn Oct 20 '15 at 17:06
  • 1
    Just adding another solution I found out: simply save the layer as a new shape file. Thanks again Matthias! – Helena Oct 20 '15 at 17:14
  • Great, I was just about to try that as well :-) – Matthias Kuhn Oct 20 '15 at 17:27

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.