1

我正在 BIDS 中构建 SSRS 报告。我需要让最终用户能够根据批准状态过滤报告。但是,每一行都有四个单独的审批列——我们将它们称为 ApprovalA、ApprovalB、ApprovalC 和 ApprovalD;每个的状态决定了该行的整体状态。这四个中的每一个都可以具有四个值之一 - 已批准、进行中、已拒绝或不适用。我的方法是根据所有四个列是否是 Approved 和 N/A 或 Rejected 和 N/A 的某种组合,或者 In Progress 是否在任何列中来创建派生列;然后,我将根据该派生列进行过滤。但是,每次运行报告时,我都会收到一条错误消息:

“[rsRuntimeErrorInExpression] 'Approval_Status' 字段的值表达式包含错误:输入字符串的格式不正确。”

据我所知,我的查询应该可以工作,但它非常复杂,而且我对 SSRS 还是新手。任何建议都会很棒。我对派生列的表达式如下:

=Switch((Fields!ApprovalA.Value OR Fields!ApprovalB.Value OR Fields!ApprovalC.Value OR Fields!ApprovalD.Value) = "Accepted" OR (Fields!ApprovalA.Value OR Fields!ApprovalB.Value OR Fields!ApprovalC.Value OR Fields!ApprovalD.Value) = "N/A", "Accepted", (Fields!ApprovalA.Value OR Fields!ApprovalB.Value OR Fields!ApprovalC.Value OR Fields!IsPFApproved.Value) = "Rejected" OR (Fields!ApprovalA.Value OR Fields!ApprovalB.Value OR Fields!ApprovalC.Value OR Fields!ApprovalD.Value) = "N/A", "Rejected", (Fields!ApprovalA.Value OR Fields!ApprovalB.Value OR Fields!ApprovalC.Value OR Fields!ApprovalD.Value) = "In Progress", "In Progress")
4

1 回答 1

1

这样的事情可能会起作用并复制您想要的逻辑:

=Switch(
  (Fields!ApprovalA.Value = "Accepted" OR Fields!ApprovalA.Value = "N/A")
    AND (Fields!ApprovalB.Value = "Accepted" OR Fields!ApprovalB.Value = "N/A")
    AND (Fields!ApprovalC.Value = "Accepted" OR Fields!ApprovalC.Value = "N/A")
    AND (Fields!ApprovalD.Value = "Accepted" OR Fields!ApprovalD.Value = "N/A")
    , "Accepted",
  (Fields!ApprovalA.Value = "Rejected" OR Fields!ApprovalA.Value = "N/A")
    AND (Fields!ApprovalB.Value = "Rejected" OR Fields!ApprovalB.Value = "N/A")
    AND (Fields!ApprovalC.Value = "Rejected" OR Fields!ApprovalC.Value = "N/A")
    AND (Fields!ApprovalD.Value = "Rejected" OR Fields!ApprovalD.Value = "N/A")
    , "Rejected",
  Fields!ApprovalA.Value = "In Progress"
    OR Fields!ApprovalB.Value = "In Progress"
    OR Fields!ApprovalC.Value = "In Progress"
    OR Fields!ApprovalD.Value = "In Progress"
    , "In Progress"
)

你有一个语法错误;就像是:

(Fields!ApprovalA.Value
  OR Fields!ApprovalB.Value
  OR Fields!ApprovalC.Value
  OR Fields!ApprovalD.Value) = "Accepted"

将导致错误,因为每个子句都需要评估为布尔值;你不能像这样嵌套字段。

于 2013-07-17T22:24:32.517 回答