SSRS: "Contains an error: [BC302205] End of statement expected."

SSRS: "Contains an error: [BC302205] End of statement expected."

我创建了一个嵌套的替换表达式,它将根据当前值更改字段中的字符串。我几乎让它工作了,但是我不确定我需要添加什么来结束声明。有人可以帮忙吗?

 =Replace(
Replace(
REPLACE (Fields!DeviceType.Value, "1", "Desktop / Laptop / Server"),
"2", "Server"),
"3", "Printer"),
"4", "Firewall"),
"5", "Managed Switch"),
"6", "Switch"),
"7", "Access Point Controller"),
"8", "Access Point"),
"9", "Desk Phone"),
"10", "Modem"),
"11", "Mobile Phone"),
"12", "DVR"),
"13", "Camera"),
"14", "NAS / SAN"),
"15", "PBX"),
"16", "UPS"),
"17", "Router"),
"18", "Monitor"),
"19", "Docking Station")

REPLACE 函数将字符串中的一段文本替换为另一段文本,因此 =REPLACE("Mobile Phone", "Mobile", "Cell") 会 return "Cell Phone"。在您的情况下,REPLACE 函数不是您所需要的。

理想情况下,您应该有一个数据库 table 可以加入并从那里获取描述,但我假设您出于某种原因不能这样做。

所以你需要的是SWITCH功能。

=SWITCH (
    Fields!DeviceType.Value = "1", "Desktop / Laptop / Server",
    Fields!DeviceType.Value = "2", "Server",
    Fields!DeviceType.Value = "3", "Printer",
    Fields!DeviceType.Value = "4", "Firewall",
    Fields!DeviceType.Value = "5", "Managed Switch",
    Fields!DeviceType.Value = "6", "Switch",
    Fields!DeviceType.Value = "7", "Access Point Controller",
    Fields!DeviceType.Value = "8", "Access Point",
    Fields!DeviceType.Value = "9", "Desk Phone",
    Fields!DeviceType.Value = "10", "Modem",
    Fields!DeviceType.Value = "11", "Mobile Phone",
    Fields!DeviceType.Value = "12", "DVR",
    Fields!DeviceType.Value = "13", "Camera",
    Fields!DeviceType.Value = "14", "NAS / SAN",
    Fields!DeviceType.Value = "15", "PBX",
    Fields!DeviceType.Value = "16", "UPS",
    Fields!DeviceType.Value = "17", "Router",
    Fields!DeviceType.Value = "18", "Monitor",
    True, "Unknown Device Type")

最终表达式的作用类似于 ELSE,以防某些数据未包含在表达式中。

如果这不起作用,请检查是否没有 leading/trailing 个空格。如果有那么你将需要使用 TRIM (TRIM(Fields!DeviceType.Value) = ...)

还要检查该字段是否为文本,如果它实际上是数字,请删除数字周围的引号。

如果您的表达式看起来不错,但您仍然对这个错误感到头疼,我建议您检查错误消息中引用的对象上的其他表达式,或者完全删除您的表达式并尝试保存。

我在看起来很干净的可见性表达式上收到了同样的错误。问题原来是一个额外的结束括号“)”,但令人沮丧的是因为错误消息说它是我三次检查的 tablix 可见性表达式并且一切都很好,它原来是一个行可见性表达式。