rdl 报告过滤总和

rdl report Filter sums

如何在 rdl 报告中为以下内容编写表达式:

Sum(Fields!Amount.Value) where AccountType='Income' - SUM(Fields!Amount.Value) where AccountType='Cost of Goods Sold')

我只使用了 1 个具有以下列的数据集 AccountType AccountName Amount

我不知道有没有其他的方法,但这是我找到的唯一方法。

在 rdl 报告中创建 2 个变量。

例如

第一个变量 IncomeTotal 我将表达式设置为

=SUM(iif(Fields!AccountType.Value="Income",CDbl(Fields!Amount.Value),CDbl(0.00)),"YourDatasetName")

第二个变量 CostOfGoodsSoldTotal 我将表达式设置为

=SUM(iif(Fields!AccountType.Value="Cost of Goods Sold",CDbl(Fields!Amount.Value),CDbl(0.00)),"YourDatasetName")

然后我用以下表达式在适当的地方减去 2 个变量

=Variables!IncomeTotal.Value - Variables!CostOfGoodsSoldTotal.Value