Salvanet wrote
> Hi, I have a Qgis layer with a table with twno columns X and Y.
> The X column has a set of values​​, while in the Y column I have to enter,
> using field calculator, for each record the progressive value. Eg : X
> column values: a , b , c , d ; Y column values (to be calculated with the
> field calculator from Y column): a; a + b; a + b + c; a + b + c + d.
> 
> How can I do this?
> 
> 
> 
>       
> thank you
> 
> _______________________________________________
> Qgis-user mailing list

> Qgis-user@.osgeo

> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user


I can suggest a way to do what (I think) you want if you transfer your table
to a database such as Spatialite or PostGIS. But first a caveat: there is no
guarantee that the order of rows in a spatial table will stay constant, so
adding values progressivley from previous rows might not work as you expect.
For example, say you split a feature into two, or add a new feature, then a
new row will be added, with some X value which might be "out of order".

Having said that warning, suppose you have a table such as:
id  X   Y
--------------
1  1  0
2  3  0
3  0  0
4  5  0
5  6  0

(Note the id column with sequntial primary keys)
A query such as:

UPDATE table SET y=(SELECT sum(t.x) FROM table as t WHERE t.id<=table.id);

will result in:
id  X  Y
---------------
1  1  1
2  3  4
3  0  4
4  5  9
5  6  15

HTH
                        



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/calculating-progressive-value-tp5280693p5280800.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to