Re: [PythonReports-users] if / else for a field value
Brought to you by:
a1s
|
From: Werner F. B. <wer...@fr...> - 2013-01-01 12:58:20
|
On 01/01/2013 12:13, Werner F. Bruhin wrote:
> Hi,
>
> I hope you got well into the New Year!
>
> In some of my reports I have conditional values, how could I do this in
> PythonReports:
>
> if ru.oCurrentvalue: # variable defined on an import alias "ru"
> currentvalue # variable from report data set
> else:
> lastpurchaseprice # variable from report data set
I am getting there:
(lambda o, c, p: c if o else p) (ru.oCurrentvalue, currentvalue,
lastpurchaseprice)
Now I just need to figure out how to do:
if ru.oShowprice:
if ru.oCurrentvalue:
currentvalue
else:
lastpurchaseprice
"lambda" gives me headaches, but I assume above can be done with a more
complex lambda - so I go get an Aspirin:)
Werner
|