I am trying to find out which functions am I supposed to use, in order to get the values that I need.
The Table should look like this. I have all the values available, now I am trying to get different form of values in a column text.
What I am trying to achieve is next:
When objekt is "Nivelation", then text should have a value of height with added letter "m".
When objekt is "GR-A", then text should have the value "A".
When objekt is "Point" and there is Value in column number, then the text should have a combined value of "P-number"
When objekt is Line and there is Value in column number, then the text should combine those two and add a direction (North, Northeast etc..)
I was trying to use different functions, like if and when, but I am not familiar with QGIS that much.
Which functions should I use and how should I write these functions in order to achieve these results?
I am using QGIS version 3.22.9 Bialowieza
I tried writing when and if functions, however, I am not sure that I even know how these functions should I use to get what I need.
1 Answer 1
After some time, I got back to this problem. Seems like CASE WHEN solves partially my problem. This is the result for the first two lines of a table. || are needed in order to solve multiple values.
CASE WHEN objekt = 'Nivelation' THEN "height" ELSE '' END || CASE WHEN objekt = 'GR-A' THEN 'A' ELSE '' END
For some reason in a "text" which has string value, my height gets point instead of comma. So I used expression replace.
replace( "text", '.', ',' )
To add m as in meter, I found next solution, with the end of a expression being important, in order not to annulate all other values.
CASE WHEN objekt = 'Nivelation' THEN concat ( "text", ' m' ) ELSE "text" END
-
You dont need to repeat the CASE each time, you just have to put it at first then as many WHEN ...THEN...as you want, if needed one ELSE after the last and you finish the case statement by END. See this question for an exemple of proper syntax gis.stackexchange.com/questions/416884/…J.R– J.R2023年08月29日 16:22:12 +00:00Commented Aug 29, 2023 at 16:22
if()
andcase when
?