2014-03-19 45 views
0

我有一个.rpt文件,与视图数据源。我有四个参数用于过滤选择。我写下了我的选择公式,如下所示。嵌套,如果其他条件在水晶报告

if ({?actype} <> "All") OR ({?actype} <> "All") OR ({?collectorname} <> "All") OR ({?batchno}<> "All") Then 
(
if {?actype} <> "All" Then 
    {CollectorPerformance.accountType} = {?actype}; 
if {?collectorname} <> "All" Then 
    {CollectorPerformance.realname} = {?collectorname}; 
if {?batchno} <> "All" Then 
    {CollectorPerformance.batchno} = {?batchno} 

and 
{CollectorPerformance.clientid} = {?clientid} 
and 
Date({CollectorPerformance.paymentdate}) >= Date({?from}) 
and 
Date({CollectorPerformance.paymentdate}) <= Date({?to}) 

) 

我的问题与上面的公式,它不会过滤realname和actType。我明白原因是因为关键词“和”缺失。然而,它正确过滤batchno>请如何使其余的两个过滤如果是?任何帮助将不胜感激。

回答

1

一个选择公式必须是一个长的有效布尔语句,也就是我认为,当你说“和缺失”时你已经建议了什么。因此,为了解决前半部分问题,您只需要将这些语句翻译为一个简化布尔语句而不是单个语句(以';'结尾)。

({?actype}="All" or {?actype}={CollectorPerformance.accountType}) 
and 
({?collectorname}="All" or {?collectorname}={CollectorPerformance.realname}) 
and 
({?batchno}="All" or {?batchno}={CollectorPerformance.batchno}) 
... 

对于每个参数,用户可以选择“全部”或输入特定值进行过滤。如果选择“全部”,语句的特定部分(看起来像{?Parameter}="All"的部分)将评估为True,并且不会执行过滤。否则,只有匹配输入参数值的记录才会返回True