SSRS切换功能是否像IIF功能一样评估所有条件的结果?

时间:2016-02-05 18:15:04

标签: vba reporting-services

许多人都知道'============================================================= 'Finds time first instance of iexplore process was started strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'iexplore.exe'") For Each objProcess in colProcessList dtmStartTime = objProcess.CreationDate strReturn = replace(split(WMIDateStringToDate(dtmStartTime), " ")(1), ":", "") exit for Next For Each objProcess in colProcessList dtmStartTime = objProcess.CreationDate strReturn1 = replace(split(WMIDateStringToDate(dtmStartTime), " ")(1), ":", "") If strReturn <> strReturn1 then objProcess.Terminate() end if Next '............................................................. Function WMIDateStringToDate(dtmStart) WMIDateStringToDate = CDate(Mid(dtmStart, 5, 2) & "/" & _ Mid(dtmStart, 7, 2) & "/" & Left(dtmStart, 4) _ & " " & Mid (dtmStart, 9, 2) & ":" & _ Mid(dtmStart, 11, 2) & ":" & Mid(dtmStart, _ 13, 2)) End Function '============================================================= 功能没有&#34;短路&#34;。 Does the iif function compute both paths in SSRS or is it short-circuited?

那么,IIF功能短路吗?换句话说,假设我们有Switch

Switch当然是一个人为的例子。

是否会导致错误,因为它会评估5/0?

1 个答案:

答案 0 :(得分:1)

Switch 不会短路。它显示与iif评估所有条件相同的行为。

但表达式Switch(True, 5, False, 5/0)不会显示#error

它会评价很好。它将显示5.由于5/0将在SSRS中评估为infinity而不是#error

更好的测试将是

=SWITCH(TRUE,5,FALSE,5/"")

使用上述表达式时,SSRS会将其评估为#error而不是5。