SSRS中如何写IF条件?

How to write IFF condition in SSRS?

我在尝试处理下面的 SSRS IIF 条件时遇到 SSRS 错误。我想根据国家/地区在屏幕上显示负责人的姓名。请查看以下表达式:

=IIF(First(Fields!DCPlayer.Value, "dsHeader") like "India" 
     OR First(Fields!DCPlayer.Value, "dsHeader") like "USA" 
     OR First(Fields!DCPlayer.Value, "dsHeader") like "Russia", 
     "Mike will handle this.", 
         IIF First(Fields!DCPlayer.Value, "dsHeader") like "UK", 
         "Hariom will handle this.", 
             IIF First(Fields!DCPlayer.Value, "dsHeader") like "France",
             "Pintu will handle this.", 
                 IIF First(Fields!DCPlayer.Value, "dsHeader") like "China" 
                 OR First(Fields!DCPlayer.Value, "dsHeader") like "Germany", 
                 "Sohan will handle this.", "Sohan will handle this."))

Error: The Value expression for the textrun ‘Textbox66.Paragraphs[7].TextRuns1’ contains an error: [BC30455] Argument not specified for parameter 'Expression' of 'Public Function IIf(Expression As Boolean, TruePart As Object, FalsePart As Object) As Object'.

此表达式似乎是 SSRS SWITCH 语句的理想用法。使用 SWITCH,您可以列出任意多个要计算的表达式,只需将它们与要在该表达式为真时使用的值配对即可。

=SWITCH([Expression to evaluate], [Value], [Expression2], [Value2]....

对于你的表达式,你应该像下面这样重写它:

=SWITCH(First(Fields!DCPlayer.Value, "dsHeader") like "India"  OR First(Fields!DCPlayer.Value, "dsHeader") like "USA" 
 OR First(Fields!DCPlayer.Value, "dsHeader") like "Russia", "Mike will handle this.", 
 First(Fields!DCPlayer.Value, "dsHeader") like "UK",  "Hariom will handle this.", 
 First(Fields!DCPlayer.Value, "dsHeader") like "France", "Pintu will handle this.", 
 True, "Sohan will handle this.")

IIF 后缺少三个左括号和两个右括号。

=IIF(First(Fields!DCPlayer.Value, "dsHeader") like "India" 
     OR First(Fields!DCPlayer.Value, "dsHeader") like "USA" 
     OR First(Fields!DCPlayer.Value, "dsHeader") like "Russia", 
     "Mike will handle this.", 
         IIF(First(Fields!DCPlayer.Value, "dsHeader") like "UK", 
         "Hariom will handle this.", 
             IIF(First(Fields!DCPlayer.Value, "dsHeader") like "France",
             "Pintu will handle this.", 
                 IIF(First(Fields!DCPlayer.Value, "dsHeader") like "China" 
                 OR First(Fields!DCPlayer.Value, "dsHeader") like "Germany", 
                 "Sohan will handle this.", "Sohan will handle this."))))

嵌套的 IIF 语句有 7 个限制,但您只有 4 个,所以这应该不是问题。