天天看点

PB的setfilter()和modify()一些不为人知的技巧

1. Setfilter(string ls_filter)

如果用到多个like来过滤数据,记得一定要为每一个like加上"( )"括起来,如:

dw_1.setfilter("((cust_name like '%ma%') or  (city like '%st%')) and (address like '%t%')") dw_1.filter( )

如果不加括号括起来:

dw_1.setfilter("cust_name like '%ma%' or  city like '%st%' and address like '%t%'") dw_1.filter( )

将出现下面的错误提示:

"Expecting TRUE/FALSE expression"

2. Modify("<Columnname>.Color='<a long>'")

当customer number =180时为绿色,当customer number = 183时为蓝色,其它值为红色,表达式如下:

dw_1.modify( "cust_name.color='0~tif(id =180, "+string(rgb(0,255,0))+", if(id = 183,"+string(rgb(0,0,255))+","+string(rgb(255,0,0))+"))'")