带过滤器的SRSS Switch不断抛出错误

时间:2017-06-20 15:18:17

标签: sql vba reporting-services

我一直试图多次调整,以为我的空检查被破坏了。在这里引用了一个空检查表:IIF Statement Null Check

这似乎对我的案件起作用了。无论如何,如果有人能够快速查看,看看他们是否能看到那个很棒的错误。

 =SWITCH(
Fields!lmItemStatus.Value, "Additional Repair Proposal Submitted - Pending Award", Year(DateAdd(DateInterval.Day, (Fields!lmFinalDelvTerms.Value + 60), Today)),

Fields!lmItemStatus.Value, "Repair Award*", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 90), Today)),

Fields!lmItemStatus.Value, "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value, "H" or "I", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 90), Fields!lmiiiSAAwardDate.Value)),

Fields!lmItemStatus.Value, "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value, "A" or "B" or "C" or "D" or "E" or "F" or "G", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 30), Fields!lmiiiSAAwardDate.Value)),

Fields!lmItemStatus.Value, "Undergoing Assessment at Repair Facility", Year(DateAdd(DateInterval.Day, (Fields!lmArmaDelvTerms.Value + fields!lmFinalDelvTerms.Value + 30), Fields!lmVendorStartDateAssess.Value)),

Fields!lmItemStatus.Value, "Assessment Complete - Pending Action", Year(DateAdd(DateInterval.Day, (Fields!lmFinalDelvTerms.Value + 60), Fields!lmAssessCompleteDate.Value)),

Fields!lmItemStatus.Value, "Final Repair Awarded" and Not(IsNothing(Fields!EstDelivDate.Value)), Year(Fields!EstDelivDate.Value),

Fields!lmItemStatus.Value, "Final Repair Awarded" and IsNothing(Fields!EstDelivDate.Value), Year(Fields!lmFinalDelvTerms.Value + 30), Today)

我一直遇到的错误是转换错误从“Lom”到“Long”类型是无效的。

2 个答案:

答案 0 :(得分:2)

你的语法错了。 Switch函数采用成对参数。这些必须是一个表达式,其值为true或false,第二个是结果,如果它是真的。所以看起来应该是这样的:

=Switch(Fields!lmItemStatus.Value = "Additional Repair Proposal Submitted - Pending Award"
    , Year(DateAdd(DateInterval.Day, (Fields!lmFinalDelvTerms.Value + 60), Today))
    , ...)

答案 1 :(得分:-1)

想出来 - 我的代码中有多个错误。在行

Fields!lmItemStatus.Value = "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value, "A" or "B" or "C" or "D" or "E" or "F" or "G", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 30), Fields!lmiiiSAAwardDate.Value)),

我没有意识到我实际上不能在开关内部使用“或”或“和”。我不得不将其拆分为每个字符串的单独开关,即:

Fields!lmItemStatus.Value = "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value = "A", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 30), Fields!lmiiiSAAwardDate.Value)),
Fields!lmItemStatus.Value = "Award Received - Pending Shipment For Assessment" & Fields!vendor.Value = "B", Year(DateAdd(DateInterval.Day, (Fields!lmADelvTerms.Value + Fields!lmFinalDelvTerms.Value + 30), Fields!lmiiiSAAwardDate.Value)),

我还试图解析日期。我不需要这样做。