15

In a QGIS 2.18.20 attribute table I have some values with random numbers, but at the print composer I want to show them with order (clockwise). So I made a new integer column, and added numbers with the way of sorting I want to appear at the print composer.

Now I can't find a way to hide the column I used for sorting the numbers. I need to use it to sort the columns, but when I delete it or do something similar the order disappears. Is there a way to keep the sorting the way I want, but to hide the sorting column? Can I do it with a different way? In the picture, Field 1 is the point number, field2&3 are the coordinates and ORDER is the sorting column

field 1 has the random numbers ORDER is the sorting column

  • Ok I hid it with a white rectangle. If you know something more professional, feel free to answer! – Pitheas Jun 1 '18 at 19:07
  • Can you copy and paste the formatted data from Excel/LibreSheet? We did that a lot with ArcMap but it commonly lost some formatting. Sometimes we got by with screen snippets of the Excel table or table pasted into the GIS map. The best looking results were done by creating pdf stamps of the table and adding them to an exported pdf map. – johns Jul 17 '18 at 13:29
  • I don't want to involve spreadsheet, the plan is to make the values shorted by the "ORDER" column but that column to be hidden from display. – Pitheas Aug 22 '18 at 16:06
  • 1
    A feature request for this functionality was made on the 8 Jan 2019 and is still open. – Joseph Oct 21 '19 at 9:45
13
+200

I suggest to use a virtual layer.

If the SQL in virtual layers would give the same result than SQL that is fired directly against databases then the following should work

select a.field_1,a.field_2,a.field_3  from
(select field_1,field_2,field_3,"ORDER" ORDER BY "ORDER") as a;

The result seems to work correctly in the print composer with QGIS 3.8.3. I wasted some time by trying to check the result by opening the attribute table of the new virtual layer in the map window with Open Attribute Table but it does not show the records like they are sorted with ORDER BY. Records are perhaps sorted also spatially. Fortunately in the print composer the order was logical and right.

My query from Create a Virtual Layer

enter image description here

Original table and sorted virtual table in Print Composer

enter image description here

| improve this answer | |
6

You could do this in a different way by sorting the layer before using the composer. So:

  1. Sort your layer with MMQGIS (plugin) by "ORDER" --> ascending.
  2. Show this new table in composer and remove the field.

Here so screen shots: Here is the data: enter image description here

Sort: enter image description here enter image description here

Check the differences: enter image description here

Plot the sorted table without that field: enter image description here

| improve this answer | |
1

I don't have 2.18 installed anymore, but I remember doing this for a project last year:

  • in the map composer, go to the table's item properties
  • in the main properties tab, click on Attributes

From there you can manipulate your columns (change field order or even hide a field from output) and choose how to sort field values (ascending or descending).

edit: Both actions (sorting from field and hiding field) can't be used concurrently. If field is hidden, it cannot be chosen as a sorting rule.

| improve this answer | |
  • That is the problem, when I short them,following the ORDER column, that column is no needed anymore for displaying in the composer. – Pitheas Aug 22 '18 at 16:08
  • After checking it out, I see what you mean. This could be a feature request for a future version, the ability to use a field from the table item for sorting while being able to hide it in composer. – Gabriel C. Aug 22 '18 at 17:03

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.