对于报表中的每一行,我都有一个字段,我需要检查另一个数据集以确定其中的数据。
这是该数据集的查询:
select t1.this, t2.that
from thisTable t1
left join thatTable t2 ON t1.id = t2.id
where t1.someId = @param1
and t2.someId = @param2
有没有办法通过表达式将参数传递给另一个数据集?
谢谢!
答案 0 :(得分:1)
您可以尝试这样的事情:
创建数据集并创建查找键:
SELECT t1.this, t2.that,
CAST(t1.someId AS VARCHAR(5)) + CAST(t2.someId AS VARCHAR(5)) as LkpKey
FROM thisTable t1
LEFT JOIN thatTable t2 on t1.id = t2.id
现在,在Field Expression中,您可以使用LookUp来获取所需的值。其中#YourIDField1
和#YourIDField2
是您希望用作LookUp的原始数据集中的值,#FieldYouWant
是您希望从LookUp数据集返回的值。
=LookUp(Fields!#YourIDField1.Value & Fields!#YourIDField2.Value,
Fields!LkpKey.Value,
Fields!#FieldYouWant.Value,
"#YourDataSet")
如果需要默认值,可以将LookUp包装在IIF中:
=IIF(LookUp(Fields!#YourIDField1.Value & Fields!#YourIDField2.Value,
Fields!LkpKey.Value,Fields!#FieldYouWant.Value, "#YourDataSet") <> nothing,
LookUp(Fields!#YourIDField1.Value & Fields!#YourIDField2.Value,
Fields!LkpKey.Value,Fields!#FieldYouWant.Value, "#YourDataSet"),
"Default")