Bug report #12174

$rownum returns 0 in labeling engine

Added by Spencer Gardner about 5 years ago. Updated about 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Labelling
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:invalid
Crashes QGIS or corrupts data:No Copied to github as #:20365

Description

Using the variable $rownum returns a value of 0 for all rows when used for labeling purposes.

Steps to replicate:
Set labeling on layer to the expression $rownum

What happens:
All labels are 0

What should happen:
Each label corresponds to the feature's row number

Tested in latest nightly from Osgeo4W. Problem also occurs in 2.6.1.

History

#1 Updated by Martin Dobias about 5 years ago

  • Resolution set to invalid
  • Status changed from Open to Closed

$rownum is only valid in the context of field calculator - in all other occurrences it will be zero. You can use $id to access feature's ID (but ID does not need to be going from 0 by steps of 1).

Also available in: Atom PDF