我花了很长时间四处寻找解决方案,并没有找到我想要的东西。为不同问题调整现有解决方案的努力也没有奏效!
我使用LookupSet返回日期列表,然后将它们连接到返回一个列表:
=Join(LookupSet(Fields!cPatSer.Value,Fields!cPatSer.Value,Fields!DDate.Value,"PatD"))
我想只显示该列表中的最新日期。这是我到目前为止所尝试的:
执行上述两项操作,但首先使用CDate和DateTime.Parse将输出转换为Date对象,如下所示...
=加入(LookupSet(字段!cPatSer.Value,字段!cPatSer.Value,CDATE(字段!DDate.Value), “PATD”))
=加入(LookupSet(字段!cPatSer.Value,字段!cPatSer.Value,DateTime.Parse(字段!DDate.Value), “PATD”))
有人可以提供任何指示吗?
答案 0 :(得分:2)
我使用自定义代码找到了解决方案。 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