2

If I open a shapefile in two empty QGIS projects and view the attribute table the rows are in completely different orders.

How does QGIS decide which order to display the rows in an attribute table and is there a way of making a shapefile display its attribute table in consistent row order? I'm using QGIS 3.4.

Just checked in version 2.14 - row order is consistent so it seems to be a version issue?

  • 1
    does it matter? if it is important pick a column and sort on that one. – Ian Turton Jul 11 at 11:01
  • It might be useful to play around with $id and @row_number in the field calculator and see what numbers you get – miln40 Jul 11 at 11:02
  • It's not the end of the world, but it's a downgrade on version 2.14 where no extra work was required to sort a table to make it consistent and you could guarantee that when another user opened the data they'd see the same rows at the top as you did – ian Jul 11 at 12:08
3

This is a known bug in QGIS 3.2. https://issues.qgis.org/issues/19299, answered in this post Attribute Table Default Order in QGIS

In QGIS 3.x the attribute rows are shown in attribute table by the order of which each one was created. Try to open your shapefile and put the mouse pointer on the first line like in the image below and QGIS will show you the creation order of that feature. Or you can sort the features by an field like id.QGIS 3.x feature creation order

  • Thanks @Francisco Camello it seems the bug is still present in 3.4 – ian Jul 11 at 12:03
3

As a complement to @Francisc0Camello answer. If you want to change the order of the features inside the shapefile permanently, you can use the Order by Expression tool.

enter image description here

You can use a single column, or you can create an expression that combines several columns to order by several columns. For example, the following example would sort features by state, and then by county name.

"STATE" + "NAME"

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.