使用动态列数在表末尾添加总计列

时间:2012-03-09 03:15:40

标签: dynamic service reporting rdl

我正在使用Reporting Services 2008.我有一个RDL如下 ![我要求打印12个月,所以我得到以下内容]

jan feb mar apr may jun jul aug sep oct nov dec Totals
 1 --- 1 ---- 1 --- 1 ----- 1 ---- 1 --- 1 --- 1 --- 1 ---- 1 --- 1 --- 1 ---- 12

现在,当我要求打印4个月时,我得到以下内容![4个月]
jan feb mar apr总计
 1 --- 1 ---- 1 --- 1 ----- 12

我希望最后的Totals列只汇总打印的月数。目前总结所有月份,因为我将以下代码置于Totals Expression之后。

=Sum(Fields!retail1.Value + Fields!retail2.Value + Fields!retail3.Value + Fields!retail4.Value + Fields!retail5.Value + Fields!retail6.Value + Fields!retail7.Value + Fields!retail8.Value + Fields!retail9.Value + Fields!retail10.Value + Fields!retail11.Value + Fields!retail12.Value)

隐藏或显示每列后面的表达式如下:

=iif(Parameters!StartMonth.Value <= 5 and Parameters!EndMonth.Value >= 5,False,true)

如何显示仅选定月份的总数。而且来自RDL本身,没有改变查询。

提前致谢。

1 个答案:

答案 0 :(得分:0)

您的总表达式应如下所示:

=Sum(IIF(Parameters!StartMonth <= 1 And Parameters!EndMonth >= 1, Fields!retail1.Value, 0)) 
+ Sum(IIF(Parameters!StartMonth <= 2 And Parameters!EndMonth >= 2, Fields!retail2.Value, 0))
+ Sum(IIF(Parameters!StartMonth <= 3 And Parameters!EndMonth >= 3, Fields!retail3.Value, 0)) 
+ ... and so on