[英]SSRS Sum Expression with Condition
I have a problem here, Have an SSRS report for Bank Transfer see attached 我在这里遇到问题,银行转账的SSRS报告见附件
I would like to add a row expression which will Sum the total amount of the same bank, ie, 03001 - Standard Chartered Bank Ltd BJL, 03002 - Standard Chartered Bank Ltd sk and 03002 - Standard Chartered Bank Base are all standard charters, i would like to get a total of all standard charters GMD figures. 我想添加一个行表达式,它将汇总同一家银行的总金额,即03001 - 渣打银行有限公司BJL,03002 - 渣打银行有限公司sk和03002 - 渣打银行基地都是标准包机,我会喜欢得到所有标准包机GMD的数字。 if need more clarification, please ask.
如果需要更多说明,请询问。
NB: Banks which are together eg Standard charters above have a common field called BankAName. 注意:像上面的标准包机一样的银行有一个名为BankAName的共同字段。 So the sum condition can be set to check if BankAName is the same.
因此可以设置总和条件以检查BankAName是否相同。
You'll need something like this: 你需要这样的东西:
=Sum(IIf(Fields!BankAName.Value = "Standard Chartered Bank"
, Fields!Amount.Value
, Nothing)
, "DataSet1")
This checks for a certain field (eg BankAName
), and if it's a certain value that row's Amount
value will be added to the total - this seems to be what you're after. 这会检查某个字段(例如
BankAName
),如果它是某个值,那么行的Amount
值将被添加到总数中 - 这似乎就是你所追求的。 You may have to modify for your field names/values. 您可能需要修改字段名称/值。
By setting the Scope of the aggregate to the Dataset this will apply to all rows in the table; 通过将聚合的范围设置为数据集,这将适用于表中的所有行; you can modify this as required.
你可以根据需要修改它。
Modify your SQL query and add the new column showing the value you want 修改SQL查询并添加显示所需值的新列
SELECT *, SUM(Amount) OVER(Partition By BankAName) AS BankANameSum
FROM myTable
Where Cond1 = Cond2
BankANameSum is the data field you can use in report design as it is. BankANameSum是您可以在报表设计中使用的数据字段。 No need to apply any logic.
无需应用任何逻辑。
HTH. HTH。
Have ended up creating a new group the groups bank branches by Banks then create a sum per group. 最后创建了一个新组,由银行分组银行分支,然后为每个组创建一个总和。 Thank you guys, your answers gave me a new perspective.
谢谢你们,你的回答给了我一个新的视角。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.