Report Builder 3.0 SWITCH 和嵌套 IIF 都抛出相同的错误 [BC32017]

Report Builder 3.0 SWITCH and nested IIF both throw the same error [BC32017]

我正在使用 Report Builder 3.0 尝试根据用户选择的参数获取动态标题。

错误

The Value expression for the textrun ‘Textbox29.Paragraphs[2].TextRuns[0]’ contains an error: [BC32017] Comma, ')', or a valid expression continuation expected.

我在使用此 SWITCH 语句时遇到此错误

=SWITCH(
Parameters!LineCalled.Count = 3, "All Lines",
Parameters!LineCalled.Count = 2, "Both Notts Lines",
Parameters!LineCalled.Count = 1 AND
Parameters!LineCalled.Value = "01156842190", "Order Line",
Parameters!LineCalled.Count = 1 AND
Parameters!LineCalled.Value = "01156842191", "Overflow Line",
Parameters!LineCalled.Count = 1 AND
Parameters!LineCalled.Value = "393607", "Belfast Line"

)

或者这个 IIF

=IIF(Parameters!LineCalled.Count = 3, "All Lines",
IIF(Parameters!LineCalled.Count = 2, "Both Notts Lines",
IIF(Parameters!LineCalled.Count = 1 AND
Parameters!LineCalled.Value = "01156842190", "Order Line",
IIF(Parameters!LineCalled.Count = 1 AND
Parameters!LineCalled.Value = "01156842191", "Overflow Line",
IIF(Parameters!LineCalled.Count = 1 AND
Parameters!LineCalled.Value = "393607", "Belfast Line","Other"
)))))

我错过了什么?

你缺少的是你的参数似乎是一个多值参数,所以每当你想访问唯一选定的值时,你应该使用表达式 Parameters!LineCalled.Value(0).

例如:

=SWITCH(
  Parameters!LineCalled.Count >= 3, "All Lines",
  Parameters!LineCalled.Count = 2, "Both Notts Lines",
  Parameters!LineCalled.Value(0) = "01156842190", "Order Line",
  Parameters!LineCalled.Value(0) = "01156842191", "Overflow Line",
  Parameters!LineCalled.Value(0) = "393607", "Belfast Line"
)