Lookupset 中的 SSRS 最大日期

SSRS Max date from Lookupset

我花了很长时间寻找解决方案,但没有找到我想要的。针对不同问题调整现有解决方案的努力也没有奏效!

我正在使用 LookupSet return 日期列表,然后将它们加入 return 列表:

=Join(LookupSet(Fields!cPatSer.Value,Fields!cPatSer.Value,Fields!DDate.Value,"PatD"))

我只想显示该列表中的最新日期。到目前为止,这是我尝试过的方法:

有人可以指点一下吗?

我找到了使用自定义代码 的解决方案。 Oz Locke 制作了一个函数,可以对整数数据进行各种聚合(下面的链接),我已经修改它以改为适用于日期。

在报告的 Code 属性 中,粘贴:

'Amended from Oz Locke's code:
'https://github.com/OzLocke/SSRSAggLookup/blob/master/AggLookup.vb
'Allows users to adjust the aggregation type of lookupsets in a cell
Function AggLookup(ByVal choice As String, ByVal items As Object)

'Ensure passed array is not empty
'Return a zero so you don't have to allow for Nothing
If items Is Nothing Then
    Return 0
End If

'Define names and data types for all variables
Dim current As Date
Dim count As Integer
Dim min As Date
Dim max As Date
Dim err As String

'Define values for variables where required
current = CDate("01/01/1900")
count = 0
err = ""

'Calculate and set variable values
For Each item As Object In items

    'Calculate Count
    count += 1

    'Check value is a number
    If IsDate(item) Then

        'Set current
        current = CDate(item)

        'Calculate Min
        If min = Nothing Then
            min = current
        End If
        If min > current Then
            min = current
        End If

        'Calculate the Max
        If max = Nothing Then
            max = current
        End If
        If max < current Then
            max = current
        End If

        'If value is not a number return "NaN"
    Else
        err = "NaN"
    End If

Next

'Select and set output based on user choice or parameter one
If err = "NaN" Then
    If choice = "count" Then
        Return count
    Else
        Return 0
    End If
Else
    Select Case choice
        Case "count"
            Return count
        Case "min"
            Return min
        Case "max"
            Return max
    End Select
End If
End Function

然后在报告的单元格中,使用以下表达式:

=code.AggLookup("max", LookupSet(Fields!cPatSer.Value,Fields!cPatSer.Value,Fields!DDate.Value,"PatD"))

https://itsalocke.com/aggregate-on-a-lookup-in-ssrs/ https://github.com/OzLocke/SSRSAggLookup/blob/master/AggLookup.vb