4

I have a lot of attributes being coded as integers like 0 meaning 'No', 1 meaning 'Perhaps', 2 meaning 'Yes' etc. I would like to show the text instead in an attribute table in a layout.

With just one attribute I would add a file with the numbers and the associated text and join this on the attribute. But I can only join a file to one attribute so I will have to duplicate the file for every attribute.

There must be an easier/smarter way to do this?

1

2 Answers 2

10

I think there is a smarter way ;-)

Consider a layer like this:

enter image description here

(0,1,2 is stored value) ...you can set up the attributes widget in the attribute forms properties of your layer to "Value Map" like this (or load them from a file as well):

enter image description here

Then in the attribute table you will have the descriptions displayed:

enter image description here

Note that still the integers are stored, the attribute form now looks like this:

enter image description here

The approach works in print layouts also:

enter image description here

You may even export the descriptions/displayed values like this (e.g. Excel):

enter image description here

...results in:

enter image description here

3

You can create a Virtual Layer. Then use this to view the data in QGIS, or export it to file.

I have one point table named building with code columns, and join two other tables types and colors which have the codes and corresponding descriptions as text,

SELECT a.*, b.typetext, colortext
FROM building a
LEFT JOIN types b
ON a.typecode=b.typecode
LEFT JOIN colors c
ON a.colorcode = c.colorcode
--keep joining all your tables

enter image description here

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.