I am working in QGIS and I have a point layer whose labels are to be displayed left or right of the point. The formula I tried to make it work is, in label placement, selected Offset from Point
mode, and built the following expression in the Quadrant:
CASE WHEN ("fid" / 6316) % 2 = 1 THEN 3 ELSE 5 END
Being 6316 the total amount of points in the layer. And 3 and 5, according to the Expression Builder, are:
[0=Above Left|1=Above|2=Above Right|
3=Left|4=Over|5=Right|
6=Below Left|7=Below|8=Below Right]
If I am correct, in this case, if the fid number is odd, it will be placed on the left-hand side, and if the fid number is even, it will be placed on the right-hand side.
At the same time, I wanted them to have 20 mm offset each side, so I built this very similar expression on the Offset X,Y
:
CASE WHEN ("fid" / 6316) % 2 = 1 THEN '-20,0' ELSE '20,0' END
However, all the labels display on the same side. I have, of course, made sure that some of the fid numbers are odd and some are even, but it seems I'm missing something pretty obvious here.