天天看點

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))+"))'")