SSRS LookupSet - Join() 有效但 Count() 无效

SSRS LookupSet - Join() works but Count() does not

这个有效:

=IIf(
    Fields!EntityID.Value Is Nothing,
    Fields!Foo.Value,
    Join(
        LookupSet(
            Fields!EntityID.Value,
            Fields!EntityID.Value,
            Fields!Bar.Value,
            "dsMain"
        )
    , ",")
)

但事实并非如此:

=IIf(
    Fields!EntityID.Value Is Nothing,
    Fields!Foo.Value,
    Count(
        LookupSet(
            Fields!EntityID.Value,
            Fields!EntityID.Value,
            Fields!Bar.Value,
            "dsMain"
        )
    )
)

我收到#Error,就像公式被破坏一样。怎么了?

您可以使用数组的长度 属性 来获取元素数

=IIf(
    Fields!EntityId.Value Is Nothing,
    Fields!Foo.Value,
        LookupSet(
            Fields!EntityId.Value,
            Fields!EntityId.Value,
            Fields!Bar.Value,
            "dsMain"
        ).Length
)