Previously asked a the same generic question (Sorting string column Qgis), but would need to know a solution in Print Composer. A added an atribute table in my print composer, and I need to sort the field.

I would like to order my field like "normal" but as this column is string and it doesn't work out. I got "Emplacement réservé 105";"Emplacement réservé 106"; .... before "Emplacement réservé 20".

What should I do? to have

Emplacement réservé 10 
Emplacement réservé 25 
Emplacement réservé 99 
Emplacement réservé 105 
Emplacement réservé 105

1 Answer 1


Using the integer field you created from your previous question, you can sort the Attribute Table depending on the field by going to:

Item properties > Main properties > Attributes...


I can think of a couple of options. The first is to create a virtual field using the answers from your previous question. This is only saved in the project file and not the shapefile itself.

Another method is to add a new field to the Attribute Table from the Print Composer which saves you from adding it to the layer itself and lets you sort your table. To do this:

  1. Go to:

    Item properties > Main properties > Attributes...

    Then click the 'plus' button to add a new column:

    Add field

  1. Highlight the first box in the new row and click the epsilon button:

    Add expression

    Use an expression like:

    to_int(regexp_substr("TXT", 'ER (.*)'))

    Then click OK. The expression will be shown as a heading for the field but you can rename this or set it empty if you so wish.

  1. Then from the Sorting tab, choose the field name with the expression, select how you wish to order it and then click the plus button.

    Add new sorting field

  1. Finall click OK and hopefully your table will include this new field and be sorted accordingly.
  • I can't create another field. this is forbidden by the reglementation. I only have thoses 2 field (LIBELE and TXT) I can use
    – Arthur
    Commented Oct 20, 2016 at 13:23
  • 2
    Use a virtual field Commented Oct 20, 2016 at 13:47
  • @MatthiasKuhn - Yup, good shout =)
    – Joseph
    Commented Oct 20, 2016 at 13:54
  • 1
    Sweet ! Gotcha Now just need to find a way to "hide" this other column. I'm gonna go with a white rectangle I suppose
    – Arthur
    Commented Oct 20, 2016 at 14:02
  • @Arthur - Yeh, that might be the best option. Don't think it's possible( yet) to filter out certain columns.
    – Joseph
    Commented Oct 20, 2016 at 14:06

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.