=Switch(Fields!CompnyID.Value=5, "company 1" "dsSalesManagement", Fields!CompnyID.Value=6, "company 2" "dsSalesManagement" )
Trying to use switch statement to display two different results in my report.
Was maybe looking for syntax correction or is there a way to use an else if statement? Problem is I want this expression to be dependent on value from another expression. Is that possible in ssrs?
答案 0 :(得分:2)
You want to use an IIF (immediate if) statement. The MSDN page is here
答案 1 :(得分:2)
语法错误在这里:
V-----------------------------V
=Switch(Fields!CompnyID.Value=5, "company 1" "dsSalesManagement",
表达式必须只返回一个值,如下所示:
=Switch(Fields!CompnyID.Value=5, "company 1" , ...)
语法是否正确,但我不清楚"dsSalesManagement"
是如何参与的,所以实际的结果表达可能会有所不同。
SSRS要求我指定数据集聚合。
然后,您可能希望使用Switch
的数据集上的计算字段返回正确的字段值,然后在聚合中使用 字段。
答案 2 :(得分:2)
您的报告中似乎有多个数据源,因此您必须指定聚合函数的正确范围。
例如:
=Switch(
First(Fields!CompnyID.Value, "dsSalesManagement") = 5, "company 1",
First(Fields!CompnyID.Value, "dsSalesManagement") = 6, "company 2"
)