SSRS不同的lookupset函数

问题描述 投票:4回答:2

我正在使用Join(Lookupset)查找返回序列号的唯一组值。这是我的功能:

Join(LookupSet(Fields!itemId.Value & Fields!UseByDate.Value & Fields!rackId.Value
    , Fields!itemId.Value & Fields!UseByDate.Value & Fields!rackId.Value
    , Fields!CustomerSeqNo.Value
    , "PickingList"), ",")

问题是某些项目有多个交易。我想删除重复项。

我发现了一个博客http://blogs.msdn.com/b/bobmeyers/archive/2012/06/18/creating-short-lists-using-the-lookupset-function.aspx,但无法获得SSRS Report Builder来引用Linq程序集。我的问题是

我怎样才能展示独特的价值?

reporting-services ssrs-2008-r2 ssrs-grouping
2个回答
11
投票

你不需要Linq,但你仍然需要自定义代码(在BIDS中转到报告 - >报告属性 - >代码)

你可以在这里放一个RemoveDuplicates函数,如下所示:

Public Shared Function RemoveDuplicates(m_Array As Object()) As String()

    System.Array.Sort(m_Array)
    Dim k As Integer = 0
    For i As Integer = 0 To m_Array.Length - 1
        If i > 0 AndAlso m_Array(i).Equals(m_Array(i - 1)) Then
            Continue For
        End If
        m_Array(k) = m_Array(i)
        k += 1
    Next

    Dim unique As [String]() = New [String](k - 1) {}

    System.Array.Copy(m_Array, 0, unique, 0, k)

    Return unique

End Function

要在您的加入中使用它:

Join(Code.RemoveDuplicates(LookupSet(...)),",")

0
投票

我同意@ user3697615报告代码是最好的。但是,我更喜欢将其直接构建为字符串:

public shared function JoinDistinct(
  dups as object(),
  delimiter as string
) as string

  dim result as string = ""
  system.array.sort(dups)

  for i as integer = 0 to dups.length - 1
    if i <> 0 then result += delimiter
    if i = 0 orElse dups(i) <> dups(i-1) then result += dups(i)
  next i

  return result

end function

这样,我们在调用中消除了一个嵌套函数:

=Code.JoinDistinct(LookupSet(...), ",")
© www.soinside.com 2019 - 2024. All rights reserved.