Re: [Qgis-user] Current item @value in expressions

2016-04-06 Thread Neumann, Andreas
Hi Enrico, 

I can't tell why this expression fails, but there is a more elegant way
to distinguish between even and odd numbers. The modulus operator (%). 

CASE WHEN @atlas_featurenumber % 2 = 0 THEN --these are the even pages
   210 - @value
 ELSE --these are the odd pages
  @value
END 

The modulus operator returns the remainder after the divison - e.g. 5 %
2 returns 1, 6 % 2 returns 0, 7 % 2 returns 1, 8 % 2 returns 0 and so
on. 

Als note, that @atlas_featureid is not a good variable to use, because
it isn't always guaranteed that the is no hole in your primary key
sequence (e.g. if you delete features) - you would also run into
troubles if you start filtering features in the atlas. I would rather
suggest to use the variable @atlas_featurenumber. This should always
start at 1 and increment by one for each subsequent atlas record,
regardless of any filter or holes in the primary key sequence. 

Hope this helps, 

Andreas 

On 2016-04-06 10:29, Enrico Ferreguti wrote:

> Is there a way to get the current item value that is being modified by 
> expressions. I would like to reformat my print composer atlas for two sided 
> printing referencing to @value variable without success:
> 
> CASE 
> WHEN  floor(  @atlas_featureid/2 )*2 =  @atlas_featureid  THEN 210 - @value
> ELSE  @value
> END
> 
> but I get always @value
> 
> ___
> 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

  ___
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

[Qgis-user] Current item @value in expressions

2016-04-06 Thread Enrico Ferreguti
Is there a way to get the current item value that is being modified by
expressions.
I would like to reformat my print composer atlas for two sided printing
referencing to @value variable without success:

CASE
WHEN  floor(  @atlas_featureid/2 )*2 =  @atlas_featureid  THEN 210 - @value
ELSE  @value
END

but I get always @value
___
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