https://issues.qgis.org/https://issues.qgis.org/favicon.ico2016-01-12T10:18:51ZQGIS Issue TrackingQGIS Application - Bug report #14083: Adding up (+) variables in expression builder results in concatenation https://issues.qgis.org/issues/14083?journal_id=671002016-01-12T10:18:51ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li><li><strong>Target version</strong> deleted (<del><i>Future Release - High Priority</i></del>)</li><li><strong>Priority</strong> changed from <i>High</i> to <i>Normal</i></li></ul><p>your fields are text, not integers or decimals, I would say that the results is the expected one.</p> QGIS Application - Bug report #14083: Adding up (+) variables in expression builder results in concatenation https://issues.qgis.org/issues/14083?journal_id=676632016-01-26T19:13:08ZNyall Dawson
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li><li><strong>Resolution</strong> set to <i>invalid</i></li></ul><p>Variables are always string values. You can convert them to a number using the expression functions to_real or to_int, eg 'to_real(@var1) + to_real(@var2)'</p> QGIS Application - Bug report #14083: Adding up (+) variables in expression builder results in concatenation https://issues.qgis.org/issues/14083?journal_id=676722016-01-27T00:18:28ZRombert Stapel
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Reopened</i></li></ul><p>That would not explain why I can multiply, subtract and divide the same numbers without any problem. The variables in question are designated as integers, not string values. In my view this is still a bug.</p> QGIS Application - Bug report #14083: Adding up (+) variables in expression builder results in concatenation https://issues.qgis.org/issues/14083?journal_id=676732016-01-27T00:26:18ZNathan Woodrow
<ul></ul><p>What are the types of the columns?</p> QGIS Application - Bug report #14083: Adding up (+) variables in expression builder results in concatenation https://issues.qgis.org/issues/14083?journal_id=676742016-01-27T00:38:02ZNyall Dawson
<ul><li><strong>Status</strong> changed from <i>Reopened</i> to <i>Closed</i></li></ul><p>Wrapping the variables in to_int/to_real is the correct solution. Multiply/etc have special handling to basically have to_real forced, but that's not possible with + because it's also reused for string concatenation. Otherwise the expression '5' + '2' would incorrectly return 7 instead of 52.</p>