SSRS中针对同一列的多个IIF语句

时间:2014-08-27 16:56:43

标签: reporting-services iif

我正在尝试在SSRS报告中的列上使用以下查询,它会抛出错误。请帮我修复此问题

=IIF((9(Fields!Project_ID.Value = "41-116") OR (Fields!Project_ID.Value = "41-116BP1")
OR (Fields!Project_ID.Value = "41-117")  OR (Fields!Project_ID.Value = "41-17")
OR (Fields!Project_ID.Value = "41-17-F") OR (Fields!Project_ID.Value = "41-181")
OR (Fields!Project_ID.Value = "41-19") OR (Fields!Project_ID.Value = "41-201")
OR (Fields!Project_ID.Value = "41-30") OR (Fields!Project_ID.Value = "41-30-A")
OR (Fields!Project_ID.Value = "41-6045") OR (Fields!Project_ID.Value = "41-80")
OR (Fields!Project_ID.Value = "36-1002") OR (Fields!Project_ID.Value = "36-37")
OR (Fields!Project_ID.Value = "45-120X01") OR (Fields!Project_ID.Value = "31-09")
OR (Fields!Project_ID.Value = "35-20-A") OR (Fields!Project_ID.Value = "35-20-N")
OR (Fields!Project_ID.Value = "42-66-1") OR (Fields!Project_ID.Value = "42-66-2")
OR (Fields!Project_ID.Value = "Goleta") OR (Fields!Project_ID.Value = "Playa Del Rey")
OR (Fields!Project_ID.Value = "1014")) ,"N/A",Fields!Permit.Value),(Fields!Project_ID.Value = "44-137") OR (Fields!Project_ID.Value = "43-121"),"NR",Fields!Permit.Value))

2 个答案:

答案 0 :(得分:2)

上面的if语句效果很好! - 作为替代方案,您也可以执行Switch语句:

=SWITCH(
    Fields!Project_ID.Value = "41-116"
 OR Fields!Project_ID.Value = "41-116BP1"
 OR Fields!Project_ID.Value = "41-117"
 OR Fields!Project_ID.Value = "41-17"
 OR Fields!Project_ID.Value = "41-17-F"
 OR Fields!Project_ID.Value = "41-181"
 OR Fields!Project_ID.Value = "41-19"
 OR Fields!Project_ID.Value = "41-201"
 OR Fields!Project_ID.Value = "41-30"
 OR Fields!Project_ID.Value = "41-30-A"
 OR Fields!Project_ID.Value = "41-6045"
 OR Fields!Project_ID.Value = "41-80"
 OR Fields!Project_ID.Value = "36-1002"
 OR Fields!Project_ID.Value = "36-37"
 OR Fields!Project_ID.Value = "45-120X01"
 OR Fields!Project_ID.Value = "31-09"
 OR Fields!Project_ID.Value = "35-20-A"
 OR Fields!Project_ID.Value = "35-20-N"
 OR Fields!Project_ID.Value = "42-66-1"
 OR Fields!Project_ID.Value = "42-66-2"
 OR Fields!Project_ID.Value = "Goleta"
 OR Fields!Project_ID.Value = "Playa Del Rey"
 OR Fields!Project_ID.Value = "1014", "N/A",

    Fields!Project_ID.Value = "44-137"
 OR Fields!Project_ID.Value = "43-121","NR",

    TRUE, Fields!Permit.Value    
)

我添加了空格,以便您可以看到每个“部分”的位置..最后的True用作“其他”。

答案 1 :(得分:1)

试试..

    =IIF(((Fields!Project_ID.Value = "41-116") OR (Fields!Project_ID.Value = "41-116BP1")
OR (Fields!Project_ID.Value = "41-117")  OR (Fields!Project_ID.Value = "41-17")
OR (Fields!Project_ID.Value = "41-17-F") OR (Fields!Project_ID.Value = "41-181")
OR (Fields!Project_ID.Value = "41-19") OR (Fields!Project_ID.Value = "41-201")
OR (Fields!Project_ID.Value = "41-30") OR (Fields!Project_ID.Value = "41-30-A")
OR (Fields!Project_ID.Value = "41-6045") OR (Fields!Project_ID.Value = "41-80")
OR (Fields!Project_ID.Value = "36-1002") OR (Fields!Project_ID.Value = "36-37")
OR (Fields!Project_ID.Value = "45-120X01") OR (Fields!Project_ID.Value = "31-09")
OR (Fields!Project_ID.Value = "35-20-A") OR (Fields!Project_ID.Value = "35-20-N")
OR (Fields!Project_ID.Value = "42-66-1") OR (Fields!Project_ID.Value = "42-66-2")
OR (Fields!Project_ID.Value = "Goleta") OR (Fields!Project_ID.Value = "Playa Del Rey")
OR (Fields!Project_ID.Value = "1014")) ,"N/A",IIF((Fields!Project_ID.Value = "44-137") OR (Fields!Project_ID.Value = "43-121"),"NR",Fields!Permit.Value))