这是图像参考。让我解释一下这个场景。
您可以看到有两个数据集A和B,数据集B具有实际测试值,数据集A具有目标值(更像是范围)。代码将每个测试(BLK ...)值与目标测试(BLK ...)值进行比较,代码如下所示
=IIF(Len(Lookup("UR_Limit",Fields!Limits.Value,Fields!BLK.Value,"Target")) <= 0,
(
IIF(Fields!BLK.Value > Lookup("UW_Limit",Fields!Limits.Value,Fields!BLK.Value,"Target"),"Yellow",
IIF(Fields!BLK.Value < Lookup("LW_Limit",Fields!Limits.Value,Fields!BLK.Value,"Target"),"Yellow","Green"))
),
(
IIF(Fields!BLK.Value > Lookup("UR_Limit",Fields!Limits.Value,Fields!BLK.Value,"Target"),"Red",
IIF(Fields!BLK.Value > Lookup("UW_Limit",Fields!Limits.Value,Fields!BLK.Value,"Target"),"Yellow",
IIF(Fields!BLK.Value < Lookup("LR_Limit",Fields!Limits.Value,Fields!BLK.Value,"Target"),"Red",
IIF(Fields!BLK.Value < Lookup("LW_Limit",Fields!Limits.Value,Fields!BLK.Value,"Target"),"Yellow","Green"))))
))
现在我面临的问题是,我无法将每个产品测试(从B)值与数据集A中的特定产品目标值进行比较。最终发生的事情是B中的每个测试都按照最后的目标产品值进行比较数据集A.
答案 0 :(得分:0)
如评论中所述,可以连接产品和限制字段。 lookup函数可以使用您传递的任何字符串来搜索值。请注意以下示例:
Lookup(Fields!Product.Value & "-" & "UR_Limit",...,"TestTargetDataSet")
它将查找905200-UR_Limit
并从测试目标值返回BLK
上限值。当然,您必须在TestTarget数据集中创建一个计算字段,并将其设置为产品和限制字段的串联。
我使用您提供的表格重新创建了您的场景。首先,我在Test Target数据集中创建了名为PRLimit
的计算字段,并将其设置为此表达式:
=Fields!Product.Value & "-" & Fields!Limits.Value
正如您在评论中提到的,您有多列,您必须为每列使用不同的表达式:
=Switch(
Fields!BLK.Value >
Lookup(Fields!Product.Value & "-" & "UW_Limit",Fields!PRLimit.Value,Fields!BLK.Value,"DataSet9"),
"Red",
Fields!BLK.Value >
Lookup(Fields!Product.Value & "-" & "Target",Fields!PRLimit.Value,Fields!BLK.Value,"DataSet9"),
"Yellow",
Fields!BLK.Value =
Lookup(Fields!Product.Value & "-" & "Target",Fields!PRLimit.Value,Fields!BLK.Value,"DataSet9"),
"Green",
Fields!BLK.Value <
Lookup(Fields!Product.Value & "-" & "LW_Limit",Fields!PRLimit.Value,Fields!BLK.Value,"DataSet9"),
"Red",
Fields!BLK.Value <
Lookup(Fields!Product.Value & "-" & "Target",Fields!PRLimit.Value,Fields!BLK.Value,"DataSet9"),
"Yellow"
)
=Switch(
Fields!BW.Value >
Lookup(Fields!Product.Value & "-" & "UW_Limit",Fields!PRLimit.Value,Fields!BW.Value,"DataSet9"),
"Red",
Fields!BW.Value >
Lookup(Fields!Product.Value & "-" & "Target",Fields!PRLimit.Value,Fields!BW.Value,"DataSet9"),
"Yellow",
Fields!BW.Value =
Lookup(Fields!Product.Value & "-" & "Target",Fields!PRLimit.Value,Fields!BW.Value,"DataSet9"),
"Green",
Fields!BW.Value <
Lookup(Fields!Product.Value & "-" & "LW_Limit",Fields!PRLimit.Value,Fields!BW.Value,"DataSet9"),
"Red",
Fields!BW.Value <
Lookup(Fields!Product.Value & "-" & "Target",Fields!PRLimit.Value,Fields!BW.Value,"DataSet9"),
"Yellow"
)
以上表达式分别用于获取BLK和BW列的正确颜色。使用的逻辑是:
UW
BLK值:红色的颜色Target
值:黄色的颜色Target
值:绿色的颜色LW
BLK值:红色的颜色Target
BLK值:黄色的颜色这是您问题中提供的数据的最终结果:
如果有帮助,请告诉我。